实用工具
本节介绍您可以与 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);
前面的示例解析任何返回的属性范围标记,并根据需要重复发出请求,直到检索到所有请求属性的所有值。