Active Directory, Win2003, LDAP Error 49 and password complexity issue
My setup:
Windows 2003 Standard, default setting (this means "password complexity requirements enabled for users account") configured as Domanin controller.
Sample code:
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class ldap {
public static void main(String[] args) {
Hashtable ldapEnv = new Hashtable();
String domain="win2003.local";
String dcList="DC=win2003,DC=local";
String port="389";
String urlDC="ldap://192.168.172.128:"+port+"/";
String UserName="user01@win2003.local";
String Password="testtest_1";
DirContext ctx=null;
String userADLocation="ou=LEVEL01, ou=MYUSERS, "+dcList;
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.SECURITY_AUTHENTICATION,"simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL,UserName);
ldapEnv.put(Context.SECURITY_CREDENTIALS,Password);
ldapEnv.put(Context.PROVIDER_URL, urlDC);
try {
ctx = new InitialDirContext(ldapEnv);
} catch (NamingException e) {
e.printStackTrace();
}
try {
Attributes attrs = ctx.getAttributes("cn=user01 user01, "+userADLocation);
System.out.println(attrs);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
Issue:
The password of user01 is set to "testtest_1" to meet the password complexity requirements (lenght>8, contains numbers and "special" characters ).
With this username/password i get "LDAP error 49" for invalid credential.
Read all the adler_steven's post and done many little change to the code, nothing changed... can't logon, always error 49.
Then i disabled the "password complexity" option on win2003, changed the password to "testtest" in AD and in the code above. LOGIN OK, ALL WORKED.
Changed again the password to "testtest_1" in AD & testcode.Error 49.
Can't find a post regarding a similar issue in this forum... has someone experienced something similar before?
Is this an AD charset issue? Maybe the password sended to AD must be formatted in some mysterious way...

