//Spring Ldap依赖项
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
LdapTemplate template;
LdapContextSource cs = new LdapContextSource();
cs.setUrl("ldap://172.18.254.210:389");
cs.setBase("DC=hans,DC=com");
//第一种
cs.setUserDn("administrator@hans.com");
cs.setPassword("123456");
//第二种
cs.setAuthenticationSource(new AuthenticationSource() {
@Override
public String getCredentials() {
return "123456";
}
@Override
public String getPrincipal() {
return "administrator@hans.com";
}
});
cs.afterPropertiesSet();
template = new LdapTemplate()
Spring LDAP连接方式
最新推荐文章于 2023-11-14 13:58:39 发布