简体   繁体   English

在LDAP中搜索用户

[英]Searching user in LDAP

I am new to LDAP and trying to write a query to authenticate a user .The root in LDAP is dc=home, dc=alpha, dc=com. 我是LDAP的新手,并尝试编写查询以对用户进行身份验证。LDAP中的根目录为dc = home,dc = alpha,dc = com。 There are many groups and users present under dc=home.It is a very deep tree with multiple nested groups and users.I have to use 在dc = home下有许多组和用户。这是一棵非常深的树,具有多个嵌套的组和用户。我必须使用

DirContext(InitialDirContext).search()


api to search the user. api搜索用户。 I read the specification of 我阅读了

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


However i could not find whether it looks for the user recursively inside the specified root,or does it just searche for the first level users or groups. 但是,我找不到它是否在指定的根目录中递归地查找用户,还是只搜索第一级用户或组。

Use SearchControls.SUBTREE_SCOPE to do it recursively or ONELEVEL_SCOPE for just that level. 使用SearchControls.SUBTREE_SCOPE递归执行此操作,或仅在该级别使用ONELEVEL_SCOPE

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

您可以在SearchControls对象中设置所需的深度行为:当前对象,较低一级或整个子树。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM