LDAP: how to authenticate a user using sAMAccountName?

I cannot authenticate when the user passes sAMAccountName and password .

If I do the following:

 env.put(Context.SECURITY_PRINCIPAL, "CN="+username+",OU=Service Accounts,OU=TECH,DC=wawalab2,DC=ins"); env.put(Context.SECURITY_CREDENTIALS, password); 

it throws an exception:

javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece

 Note: I can use Spring LDAP framework too. 
+4
source share
1 answer

Firstly, error 525 is a bad DN. You can see the list of LDAP errors returned by AD at this link: AD LDAP Error Codes

So you have a bad DN. What you want to do is search for the name samAccountName = username, get the DN from the return value, and bind to that correct DN.

+3
source

All Articles