Need Help withAuthentication after password change.

Hi

I have to check always the user and his password against AD. the user would be using his email to login to the application. hence i need to get his principalName and then reauthenticate him. I am using a default user and password to search and get the principalName.

This small piece of code achieve it.

publicstaticvoid main(String[] args){

// Identify service provider to use

Control[] connCtls =null;

Hashtable env =new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL,"ldap://192.168.0.18/dc=mydomain,dc=com");

env.put(Context.SECURITY_AUTHENTICATION,"simple");

env.put(Context.SECURITY_PRINCIPAL,"defaultUser@mydomain.com");

env.put(Context.SECURITY_CREDENTIALS,"p@ssw0rd");

DirContext ctx1 =null;

try

{

// Create the initial directory context

LdapContext ctx =new InitialLdapContext(env,connCtls);

SearchControls constraints =new SearchControls();

constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);

NamingEnumeration e2 = ctx.search("","mail=testUser@myEmail.com",constraints);

while(e2.hasMoreElements())

{

System.out.println("LdapLookUp.main()-searched");

SearchResult nc = (SearchResult)e2.nextElement();

Attributes atrr = nc.getAttributes();

String userPrincipalName = (String)atrr.get("userPrincipalName").get();

System.out.println("main()-Atrr-"+userPrincipalName);

ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, atrr.get("userPrincipalName").get());

ctx.addToEnvironment(Context.SECURITY_CREDENTIALS,"testp@ssw0rd");

ctx.reconnect(null);

System.out.println("main()-Reconnected");

}

}

catch(Exception e)

{

e.printStackTrace();

}

}

i run this class successfully, Now if the administrator resets the user password on AD and if i still run the same class using the old password it works fine... :(

I have tried using closing the context and then opening a new context also. Any suggestions regarding this would be very helpful

[3164 byte] By [skioa] at [2007-11-26 19:16:18]
# 1
Refer to http://support.microsoft.com/?kbid=906305, which describes why you are still able to successfully authenticate with the old password.
adler_stevena at 2007-7-9 21:29:14 > top of Java-index,Core,Core APIs...
# 2

Thanks very much for the info... I used the registry fix method suggested and it worked successfully.

But what i did not understand is the kb info is for change of password using NTLM but here the Administrator used the AD UI itself. and the program uses LdapContext (JNDI)... so it should have worked right.

Oh one more thing how did you figure out the problem was NTLM issue? :)

skioa at 2007-7-9 21:29:14 > top of Java-index,Core,Core APIs...