我希望有人可以帮助我了解如何处理调用 DirContext.lookup 返回的对象.
I'm hoping someone can help me understand how to work with the object returned by a call to DirContext.lookup.
以下代码片段有效并返回一个对象.我只是不知道如何从对象中获取属性.
The following code snippet works and returns an object. I just can't figure out how to get the attributes from the object.
javax.naming.directory.DirContext ctx =
javax.naming.directory.getContext(false);
Object o = ctx.lookup(rdn);
任何帮助将不胜感激.
属性 attrs = ctx.getAttributes(dn);假设请求 artibute 值的条目具有适当的权限,则将检索用户属性.
Attributes attrs = ctx.getAttributes(dn); will retrieve the user attributes assuming the entry asking for the arrtibute values has proper rights.
但是,最佳做法是只查询所需的属性.
However, best practice is you only query for the attributes you need.
如果您希望查看所有属性,您应该查询 objectclass 属性值,然后查询架构以获取所有"分配的属性并决定您需要检索哪些属性.
If you wish to see all attributes, you should query the objectclass attribute values and then query the schema to obtain "all" the attributes assigned and decide which attributes you need to retrieve.
-吉姆
这篇关于如何访问此 LDAP 对象的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!