Getting Internal Attributes of LDAP Object

扶醉桌前 提交于 2019-12-07 03:16:37

问题


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

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


回答1:


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.

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



来源:https://stackoverflow.com/questions/18607828/getting-internal-attributes-of-ldap-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!