posted 14 years ago
I have the following configuration:
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"
destroy-method="close">
<property name="url" value="ldap://${LDAP_HOST}:${LDAP_PORT}"/>
<property name="base" value="${LDAP_BASEDN}"/>
<property name="pooled" value="false" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
<property name="ignorePartialResultException" value="true" />
</bean>
I have following properties:
LDAP_ENABLE = 1
LDAP_HOST = 10.X.X.X
LDAP_PORT = 389
LDAP_BASEDN = DC=pune,DC=com
LDAP_FILTER =(&(objectClass=person)(sAMAccountName=?))
LDAP_ANONYMOUS = false
LDAP_OBJECT_CLASS = person
LDAP_SEARCH_FILTER = sAMAccountName
I have following source code:
contextSource.setAnonymousReadOnly(Boolean.parseBoolean(utilProperties.getProperty("LDAP_ANONYMOUS")));
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setIgnorePartialResultException(true) ;
ldapTemplate.afterPropertiesSet();
AndFilter filter1 = new AndFilter();
filter1.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("sAMAccountName", userName));
ldapTemplate.authenticate(contextSource.getBaseLdapPath().toString(), filter1.toString(), password);
But when I attempt to authenticate I get the following error:
org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of:
'DC=pune,DC=com' ];
nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of:
'DC=pune,DC=com' ];
remaining name 'dc=pune,dc=com'Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of:
'DC=pune,DC=com' ]; remaining name 'dc=pune,dc=com'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.searchAux(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(Unknown Source)
at javax.naming.directory.InitialDirContext.search(Unknown Source)
at org.springframework.ldap.core.LdapTemplate$3.executeSearch(LdapTemplate.java:231)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:293)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:237)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:624)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:535)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:462)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:483)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:503)
at org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1424)
at org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1410)
at org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1397)
at com.dmsuite.web.user.LoginController.authenticate(LoginController.java:113)
at com.dmsuite.web.user.LoginController.processFormSubmission(LoginController.java:251)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormContro
ller.java:250)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAd
apter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
please let me know if anyone has solution.
thanks in advance..