我想答案就在这里:http://forum.spring.io/forum/spring-projects/data/ldap/66894-objectsid-and-ldaptemplate http://forum.spring.io/forum/spring-projects/data/ldap/66894-objectsid-and-ldaptemplate
在倒数第二篇文章中,他描述了您遇到的同样问题。在上一篇文章中,他描述了一个修复方法,即将其添加到 Bean 配置文件中:
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://ldapserver.domain.com:389" />
<property name="base" value="dc=domain,dc=com" />
<property name="userDn" value="cn=binduser,cn=Users,dc=domain,dc=com" />
<property name="password" value="bindpwd"/>
<property name="baseEnvironmentProperties">
<map>
<entry key="java.naming.ldap.attributes.binary">
<value>objectSid</value>
</entry>
</map>
</property>
</bean>
您必须修改域的值,但我认为重要的部分是baseEnvironmentProperties
.
这个线程 http://forum.spring.io/forum/spring-projects/data/ldap/47556-binary-attributes-objectguid-programmatically-set-the-environment还描述了一种编程方式来设置它(尽管,对于objectGuid
,但您可以只交换属性)。
AbstractContextSource contextSource = (AbstractContextSource) ldapTemplate.getContextSource();
Map<String,String> baseEnvironmentProperties = new HashMap<String, String>();
baseEnvironmentProperties.put("java.naming.ldap.attributes.binary", "objectSid");
contextSource.setBaseEnvironmentProperties(baseEnvironmentProperties);
contextSource.afterPropertiesSet();