问题描述
我希望有人可以帮助我了解如何处理调用 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 对象的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)