2014-10-16 85 views
0

我是LDAP新手,試圖編寫查詢來驗證用戶。LDAP中的根目錄是 dc = home,dc = alpha,dc = com。 有下DC目前衆多用戶= home.It是多重嵌套 組和users.I了非常深刻的樹必須使用
在LDAP中搜索用戶

DirContext(InitialDirContext).search() 


API來搜索用戶。 我讀的

public NamingEnumeration<SearchResult> search(String name,String filter,SearchControls cons) 


規範但是我找不到它是否查找用戶遞歸指定的根裏面,或者 不只是搜索器的第一級用戶或組。

回答

2

使用SearchControls.SUBTREE_SCOPE遞歸或ONELEVEL_SCOPE爲那個級別。

ctx = getContext(); 
    SearchControls constraints = new SearchControls(); 
    constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); 
    result = ctx.search(searchPath, searchFilter, constraints); 
1

您可以在SearchControls對象中設置所需的深度行爲:當前對象,低一級或整個子樹。