In my current project, I have to implement LDAP authentication. I am using JSF 2.2, primefaces and Spring 4.0 and spring -ldap-core 1.3.2 and spring -security-ldap-3.2.0. The following are the work that I still did to achieve:
Spring -Ldap.xml
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://mumcXXXXXXX" />
<property name="base" value="dc=ad,dc=XXX,dc=com"/>
<property name="userDn" value="XXXX@ad.XXX.com" />
<property name="password" value="XXXX" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="ldapContact"
class="com.csap.research.LDAPContactDAO">
<property name="ldapTemplate" ref="ldapTemplate" />
</bean>
My LdapContactDao
public boolean login(String username, String password) {
AndFilter filter = new AndFilter();
ldapTemplate.setIgnorePartialResultException(true);
filter.and(new EqualsFilter("userPrincipalName", username+"@ad.cXXX.com"));
return ldapTemplate.authenticate("", filter.toString(), password);
}
Here, the username and password come from the login screen as input. My problem is very tough. I do not want to hardcode the username and password in Spring -Ldap.xml . Therefore, it was suggested to use spring -security -Ldap here Spring roles LdapAuthentication and Load from the local database , but I could not figure it out.
, Ldap Spring corse JSF, .
.