实用工具

本节描述了可与 Spring LDAP 配合使用的其他实用工具。

多值属性的增量检索

当某个特定属性的属性值数量非常大(>1500)时,Active Directory 通常会拒绝一次性返回所有这些值。相反,属性值会根据多值属性的增量检索方法返回。这要求调用方检查返回的属性中是否存在特定标记,并在必要时发出额外的查找请求,直到找到所有值。

Spring LDAP 的 org.springframework.ldap.core.support.DefaultIncrementalAttributesMapper 在处理这类属性时很有帮助,如下所示:

Object[] attrNames =  new Object[]{"oneAttribute", "anotherAttribute"};
Attributes attrs = DefaultIncrementalAttributeMapper.lookupAttributes(ldapTemplate, theDn, attrNames);

前面的示例解析任何返回的属性范围标记,并根据需要重复发出请求,直到检索到所有请求属性的所有值。

© . This site is unofficial and not affiliated with VMware.