如何访问此LDAP对象的属性? [英] How can I access the attributes of this LDAP object?

查看:144
本文介绍了如何访问此LDAP对象的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以帮助我理解如何处理通过调用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); 假设要求arribute值的条目具有适当的权限,将检索用户属性.

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对象的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆