简体   繁体   English

LDAP和属性(LDAP)

[英]Ldap and attributes(LDAP)

Hi I am a developer but new to ldap programming. 嗨,我是一名开发人员,但是ldap编程的新手。 I was able to our Ldap server by providing the DN=ou=app1,ou=development,ou=Group and set my search level to subtree_scope and was able to get to on level down which put me at DN=cn=admin,DN=ou=app1,ou=development,ou=Group . 我可以通过提供DN = ou = app1,ou = development,ou = Group将Ldap服务器连接到我们的Ldap服务器,并将搜索级别设置为subtree_scope,并能够降低级别,这使我的DN=cn=admin,DN=ou=app1,ou=development,ou=GroupDN=cn=admin,DN=ou=app1,ou=development,ou=Group By expanding this DN i see Member(4) , OU(1) , cn(1) ,and Objectclasses: top and groupOfNames . 通过扩展此DN,我可以看到Member(4)OU(1)cn(1)和Objectclasses: topgroupOfNames I am trying to access the 4 users with uid=user entries. 我正在尝试使用uid=user条目访问4个用户。 I got the below message when i tried to access uid : 我尝试访问uid时收到以下消息:

UID... class javax.naming.directory.SearchResult UID ...类javax.naming.directory.SearchResult

null Found cn=Admin: null找到cn = Admin:

Attributes are.. No attributes 属性是..没有属性

The following is the snippet of my code. 以下是我的代码段。 I can provide more if needed 如果需要,我可以提供更多

    controls.setReturningAttributes("uid");
    String filter="(objectClass=groupOfNames)"; 

        NamingEnumeration objs = ctx.search("",filter, controls); 


        while (objs.hasMoreElements())
                {

                SearchResult match = (SearchResult)objs.nextElement();

               System.out.println(" UID...\t"+ match.getClass());
               System.out.println(match.getClassName());
               System.out.println("Found "+match.getName()+":");
               System.out.println("Attributes are..\t"+match.getAttributes());


                Attributes attrs = match.getAttributes();
                NamingEnumeration e = attrs.getAll();


                while (e.hasMoreElements())
                {

                    Attribute attr = (Attribute) e.nextElement();
                   System.out.println("Attribute and its class..\t"+attr.getClass());


                }
                System.out.println("---------------------------------------");
            }
                }

The SearchControls define the attributes to be returned by the search. SearchControl定义要由搜索返回的属性。 You must have set its 'returningAttributes' property to 'new String[0]'. 您必须将其“ returningAttributes”属性设置为“ new String [0]”。 Leave it at null to get all attributes, or specify the ones you want. 将其保留为空以获取所有属性,或指定所需的属性。

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

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