Getting Internal Attributes of LDAP Object(获取 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]
推荐答案
除非您要求,否则您不会获得任何操作属性.目前不要求任何属性,相当于构造SearchControls,或者之后调用SearchControls.setReturningAttributes(String[]),使用参数new 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.
要同时获取操作属性,请使用参数 new String[]{"*","+"}.
To get the operational attributes as well, use the argument new String[]{"*","+"}.
这篇关于获取 LDAP 对象的内部属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取 LDAP 对象的内部属性
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
