'LDAP Authentication failure while using LDAP template : org.springframework.ldap.AuthenticationException: AcceptSecurityContext error, data 52e, v3839
I am trying to do a user search using SpringBoot Ldaptemplate but I am facing the below error:
org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090447, comment: AcceptSecurityContext error, data 52e, v3839
The same credentials work fine when I use it with Active Directory Tool Could you please help me out here?
My Code changes are as follows:
// Application.property
spring.ldap.urls=ldap://test.corpdir.net:112
spring.ldap.base =DC=test,DC=corpdir,DC=net
spring.ldap.username=testdomain\\test_group_user
spring.ldap.password=password
//Config
@Configuration
@EnableLdapRepositories(basePackages = "com.test.repository", ldapTemplateRef="ldapTemplate1")
@EnableConfigurationProperties(LdapProperties.class)
public class TestLdapConfiguration {
@Autowired
Environment env;
@Bean(name="ldapProperties")
@ConfigurationProperties(prefix="spring.ldap")
public LdapProperties ldapProperties() {
return new LdapProperties();
}
@Bean(name="contextSource1")
public LdapContextSource contextSource1(@Qualifier("ldapProperties")LdapProperties ldapProperties) {
LdapContextSource source = new LdapContextSource();
source.setUserDn(ldapProperties.getUsername());
source.setPassword(ldapProperties.getPassword());
source.setBase(ldapProperties.getBase());
source.setUrls(ldapProperties.determineUrls(this.env));
return source;
}
@Bean(name="ldapTemplate1")
public LdapTemplate ldapTemplate(@Qualifier("contextSource1") LdapContextSource contextSource){
return new LdapTemplate(contextSource);
}
}
// Service Code
public List<Person> findUser(String userId) {
List<Person> persons = null;
try {
SearchControls sc = new SearchControls();
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
sc.setCountLimit(10);
String filter = "(&(objectclass=User)(dcxUid=" +userId + "))";
ldapTemplate1.setIgnorePartialResultException(true);
persons = ldapTemplate1.search(LdapUtils.emptyLdapName(), filter, sc, new
PersonAttributesMapper());
}catch (Exception e) {
e.printStackTrace();
}
I am trying to do a user search using SpringBoot Ldaptemplate but I am facing the below error:
org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090447, comment: AcceptSecurityContext error, data 52e, v3839
The same credentials work fine when I use it with Active Directory Tool Could you please help me out here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
