【发布时间】:2019-07-09 21:19:38
【问题描述】:
我正在尝试构建一个使用弹簧数据的 LdapTemplate 对象。
public class LDAPTemplate {
public static void main(String[] args) {
LdapContextSource lcs = new LdapContextSource();
lcs.setUrl("ldap://localhost:389/");
lcs.setUserDn("cn=Manager, dc=example, dc=com");
lcs.setPassword("secret1");
lcs.setDirObjectFactory(DefaultDirObjectFactory.class);
LdapTemplate ldap = new LdapTemplate(lcs);
ldap.lookup("cn=aaa");
}
}
我想知道的是实例化 ldap 模板对象的正确方法。因为当我执行查找时,它会抛出 NPE。
我试图在 CDI 上下文中使用 LDAP Spring,而根本不使用 spring。如果您对此有指示会很好。 Spring LDAP是否依赖spring?
【问题讨论】:
标签: spring ldap spring-ldap