3
我正在嘗試使用range屬性。LDAP AD - 範圍屬性,如何使用它?
爲了測試,我使用了一個沒有範圍返回3項的搜索,我將範圍設置爲0-1,它應該只返回前2個。但是,我得到了全部3個結果。
這是我要做的事:
String rangeStr = attribute + ";range=0-1";
String returnedAttrs[] = {rangeStr, attribute};
_searchControls.setReturningAttributes(returnedAttrs);
_searchControls.setSearchScope(scope);
NamingEnumeration<SearchResult> answer = _context.search(name, filter, _searchControls);
List<String> result = new LinkedList<String>();
while (answer != null && answer.hasMoreElements())
{
Attribute currentAttr = answer.next().getAttributes().get(attribute);
if (currentAttr == null)
continue;
for (int i=0; i<currentAttr.size(); i++)
{
String val = currentAttr.get(i).toString();
result.add(val);
}
}
我在做什麼錯?
我使用的頁面大小爲1000,但是如果我理解正確,那不會影響範圍搜索(假定頁面大小大於請求的範圍)。那是對的嗎?
這仍然是你的問題嗎? – serialhobbyist 2009-08-12 17:11:28