I can authenticate Active Directory with a user configured while using ContextSource using Spring -ldap. My Spring xml configuration looks lilke:
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <property name="contextSource" ref="contextSource" /> </bean> <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> <property name="url" value="ldap://xxx.xxx.xxx.xxx:389" /> <property name="userDn" value=" myName@xxx.xxx " /> <property name="password" value="password" /> </bean>
Java code for user authentication:
public boolean login(String username, String password) { AndFilter filter = new AndFilter(); this.ldapTemplate.setIgnorePartialResultException(true);
The same thing works with Linux opening Ldap v3, even if I do not set the userDn property and password inside the contextSource bean.
All I need to do is configure this xml so that I can access Active Directory as an anonymous user (without setting userDn and password).
I also need to go through user authentication through SSL. For this I used
<property name="url" value="ldaps://xxx.xxx.xxx.xxx:636" />
but I got an exception like:
Exception in thread "main" org.springframework.ldap.CommunicationException: simple bind failed: 192.168.0.13:636; nested exception is javax.naming.CommunicationException: simple bind failed: 192.168.0.13:636 [Root exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target]
Although I got a solution while searching, I need to specify the keystore where the certificates are stored. Here I am not sure where it is (either in the java class or in the XML file).
Your prompt reply will be appreciated. Thanks.
source share