java - 使用 Spring LDAP 验证用户身份时出现异常

标签 java spring ldap spring-ldap

我在验证用户身份时遇到以下异常:

Exception in thread "main" org.springframework.ldap.PartialResultException: Unprocessed Continuation Reference(s); nested exception is javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name '/'
    at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:205)

验证方法:

public boolean authenticate(String userName, String password) {
        AndFilter filter = new AndFilter();
        filter.and(new EqualsFilter("objectclass", "person")).and(
                new EqualsFilter("sAMAccountName", userName));
        return ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, filter
                .toString(), password);
    }

Applicationcontext.xml

<bean id="contextSource"
        class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://10.10.10.10:389" />
        <property name="base" value="DC=lab2,DC=ins" />
        <property name="userDn" value="CN=Ldap Bind,OU=Service Accounts,OU=TECH,DC=lab2,DC=ins" />
        <property name="password" value="secret" />
    </bean>
    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
        <constructor-arg ref="contextSource" />
    </bean>
    <bean id="ldapContact"
        class="ldap.ContactLDAP ">
        <property name="ldapTemplate" ref="ldapTemplate" />
    </bean>

测试类:

Resource r = new ClassPathResource("applicationContext.xml");
        BeanFactory factory = new XmlBeanFactory(r);
        ContactLDAP contact = (ContactLDAP) factory.getBean("ldapContact"); 

        System.out.println(contact.authenticate("username", "secret"));

我在这里缺少什么?

最佳答案

尝试通过设置java.naming.referral=follow来跟踪引用。

关于java - 使用 Spring LDAP 验证用户身份时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12159525/

相关文章:

java - JMH 超时不中断

java - Spring Profiles 奇怪的行为

c# - LDAP 到大型机环境

java - 一天内制作一个简单的可搜索人员及其技能目录 - 哪些技术?

Java 6 重新定义货币符号(通过CurrencyNameProvider?)

java - Spring,SockJS - WebSocket 握手期间出错 : Unexpected response code 400

java - Spring数据jpa deleteBy查询不起作用

java - Java 中 uid 的 LDAP 搜索过滤器

java - 使用 LDAP 在 java 中进行用户和角色管理

java - 在一个方法调用中在 JPA 中创建两个单独的事务