
April 20th, 2012, 01:41 AM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 1
Time spent in forums: 48 m 38 sec
Reputation Power: 0
|
|
|
LDAP authentication
Hello everyone,
I have a java class for simple ldap authentication (true or false).
Premise that, obviously, username and password are correct, the server address is correct, I have tried solutions practically anywhere.
The code is:
Code:
public class jcInterrogaLDAP {
public boolean InterrogaLDAP(String usr, String psw) {
boolean blLdapVerify = false;
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://atmdc03:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=" + usr + ",conn");
env.put(Context.SECURITY_CREDENTIALS, psw);
try {
DirContext authContext = new InitialDirContext(env);
// Authentication OK
blLdapVerify = true;
authContext.close();
} catch (AuthenticationException authEx) {
authEx.getMessage();
// Authentication failed
blLdapVerify = false;
} catch (NamingException namEx) {
namEx.getMessage();
// Something went wrong
blLdapVerify = false;
}
return blLdapVerify;
}
}
The error message is:
Code:
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C09030B, comment: AcceptSecurityContext error, data 525, v893]
Someone sees a mistake?
Thanks
Massimo
|