【问题标题】:Getting Internal Attributes of LDAP Object获取 LDAP 对象的内部属性
【发布时间】:2013-09-07 14:32:11
【问题描述】:

我正在尝试获取 LDAP 用户内部属性,但找不到如何获取它们

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]

【问题讨论】:

    标签: java attributes ldap jndi


    【解决方案1】:

    除非您要求,否则您不会获得任何操作属性。目前你不要求任何属性,相当于构造SearchControls,或者之后调用SearchControls.setReturningAttributes(String[]),使用参数new String[]{"*"}:this给你所有的非操作属性。

    要同时获取操作属性,请使用参数new String[]{"*","+"}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多