简体   繁体   English

如何通过ldap中的特定对象类获取所有属性定义?

[英]How to get all attributes definition by a specific object class in ldap?

My aim is to retrieve all attributes defined on LDAP server by a given objectclass. 我的目的是检索给定对象类在LDAP服务器上定义的所有属性。 What I have done so far is: 到目前为止,我所做的是:

List<SearchResult> searchLdapUsers = searchLdapUsers(ldapConfig, null, null, null, null, null, 0);
if (searchLdapUsers != null  && searchLdapUsers.size() > 0) {
    for (SearchResult searchResult : searchLdapUsers) {
        Attributes attrs = searchResult.getAttributes();
        if (attrs != null) {
            NamingEnumeration<? extends Attribute> all = attrs.getAll();
            while (all.hasMoreElements()) {
                Attribute attribute = (Attribute) all.nextElement();
                hs.put(attribute.getID(), attribute.getID());
            }
        }
    }
}

This code will query all users from LDAP server and get attribute definition. 此代码将从LDAP服务器查询所有用户并获取属性定义。 This is working fine but will get problem with large number of users. 这工作正常,但会给大量用户带来麻烦。

Is there any other way to find directly the given object class and get all attribute definition inside? 还有其他方法可以直接找到给定的对象类并在其中获取所有属性定义吗?

Most LDAP servers expose their schema through LDAP, and per LDAP specifications, every entry should have an operational attribute (subSchemaSubEntry) that points to the Schema entry. 大多数LDAP服务器都通过LDAP公开其架构,并且根据LDAP规范,每个条目都应具有一个指向该架构条目的操作属性(subSchemaSubEntry)。 So reading the schema, should give you all objectClasses and their attributes definitions. 因此,阅读架构应为您提供所有objectClasses及其属性定义。

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

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