工具程式

本節介紹您可以搭配 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);

前面的範例會解析任何傳回的屬性範圍標記,並在必要時重複發出請求,直到檢索到所有請求屬性的所有值。