您的位置 首页 Java

java – 获取LDAP对象的内部属性

我试图获取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,我也想获取每个员工/个人的内部属性.
默认情况下,它不返回内部属性[ex:createTimestamp]

解决方法

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

要获取操作属性,请使用参数new String [] {“*”,“”}.

关于作者: dawei

【声明】:金华站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

热门文章