我一直试图找到一种方法来发现目录上下文中对象类支持的所有属性。我曾尝试使用目录上下文的getattributes()
方法,但这只显示那些已填充的属性。我感兴趣的是发现只支持特定对象类的所有属性,而不是所有对象类的所有属性。以下是我已经尝试过的代码片段。
//接近1
System.out.println("using bindings.......");
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope( SearchControls.OBJECT_SCOPE );
searchControls.setReturningAttributes( new String[]
{ "objectClasses" } );
NamingEnumeration<SearchResult> results = conn.getInitialContext().search( "cn=schema", "(ObjectClass=*)", searchControls );
SearchResult result = results.next();
Attributes entry = result.getAttributes();
javax.naming.directory.Attribute objectClasses = entry.get( "objectClasses" );
System.out.println( objectClasses );
System.out.println("................................");
//接近2
DirContext tedClasses = (conn.getInitialContext().getSchemaClassDefinition(entryName));
// Enumerate the class definitions
NamingEnumeration namingEnum = tedClasses.search("", null);
System.out.println("attrs are:");
while (namingEnum.hasMore()) {
System.out.println(namingEnum.next());
}
conn.getInitialContext()
给出目录上下文
答案 0 :(得分:-1)
你能执行一个指定objectclass=x
的ldapsearch(x是你想要的对象类)吗?
所以搜索人的对象类,例如
ldapsearch -h <host> -p <port> -D <useraccount> -w \? -b <search string> objectclass=person