實用工具
本節描述了可與 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);
前面的示例解析任何返回的屬性範圍標記,並根據需要重複發出請求,直到檢索到所有請求屬性的所有值。