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