Active Directory, Password Expired

14. May 2007 08:46 by Mrojas in General  //  Tags:   //   Comments (0)
There are a list of situations you might want to handle with Active Directory:

525 - user not found
52e - invalid credentials
530 - not permitted to logon at this time
532 - password expired
533 - account disabled
701 - account expired
773 - user must reset password

 
This is an extract of the Java Forum to handle these cases. Good Luck!
 
} catch (AuthenticationException e) {
String tempString;
StringTokenizer tokenizerTemp = new StringTokenizer(e.toString());
while (tokenizerTemp.hasMoreElements()) {
         tempString = tokenizerTemp.nextToken();
         if (tempString.equalsIgnoreCase("AcceptSecurityContext")) {
                 while (tokenizerTemp.hasMoreElements()) {
                          tempString = tokenizerTemp.nextToken();
                          if (tempString.startsWith("773"))
                                   setIsPasswordExpired(true);
                          if (tempString.startsWith("52e"))
                                   setIsPasswordWrong(true);
                          if (tempString.startsWith("533"))
                                   setIsAccountDisabled(true);
                 }
         }
}
throw new NamingException();
}