获取LDAP对象的内部属性 [英] Getting Internal Attributes of LDAP Object

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

问题描述

我试图获取LDAP用户的内部属性,但无法找到如何获取它们。

I am trying to fetch LDAP User internal attributes, but couldn't find how to fetch them

DirContext ctx = this.getDirContext();
List<Employee> list = new ArrayList<Employee>();
NamingEnumeration<SearchResult> results = null;
try {
  SearchControls controls = new SearchControls();
  controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
  results = ctx.search("", "(objectclass=person)", controls);
  while (results.hasMore()) {
    SearchResult searchResult = results.next();
    Attributes attributes = searchResult.getAttributes();
    String fullName = this.getValue(attributes.get("cn"));
    //so on...
}
// so on

从LDAP,我想获取每个员工/人的内部属性。
默认情况下,它没有返回的内部属性[例如:createTimestamp]

from LDAP, I want to fetch each employee/person internal attributes too. By Default, it's not returning the internal attributes [ex: createTimestamp]

推荐答案

除非你问他们你不会得到任何操作属性。在present你不要求任何属性,相当于构建 SearchControls ,或致电 SearchControls.setReturningAttributes(字符串[] )之后,使用参数新的String [] {*}:这给你所有的非经营性的属性。

You won't get any operational attributes unless you ask for them. At present you aren't asking for any attributes, which is equivalent to constructing the SearchControls, or calling SearchControls.setReturningAttributes(String[]) afterwards, using the argument new String[]{"*"}:this gives you all the non-operational attributes.

要获得操作属性为好,使用参数新的String [] {*,+}

To get the operational attributes as well, use the argument new String[]{"*","+"}.

这篇关于获取LDAP对象的内部属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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