【发布时间】:2017-02-01 00:52:18
【问题描述】:
我正在尝试获取、存储并反过来使用 objectGUID 来查询 Active Directory。 要获取用户属性,我正在使用以下
public static class MyDnKeyValueAttMapper implements AttributesMapper<Object> {
@Override
public List<LdapKeyValueList> mapFromAttributes(Attributes attributes)
throws NamingException, javax.naming.NamingException {
List<LdapKeyValueList> attributeKeyValMap = new ArrayList<LdapKeyValueList>();
NamingEnumeration<String> namingEnumeration = attributes.getIDs();
while (namingEnumeration.hasMoreElements()) {
String attributeName = (String) namingEnumeration.nextElement();
String AttributeValue = attributes.get(attributeName).get().toString();
attributeKeyValMap.add(new LdapKeyValueList(attributeName, AttributeValue));
}
return attributeKeyValMap;
}
}
objectGuid 似乎总是以字符串格式返回。 我也试过-
UUID guid = (UUID) attributes.get("objectGUID").get();
这会引发“无法将字符串转换为 uuid”的错误
似乎在我可以做任何事情之前 ldaptemplate 搜索总是以字符串格式返回属性。
如何获取“objectGUID”的格式,以便我可以存储它并在 ldapTemplate 搜索查询中使用。
提前致谢。
【问题讨论】:
标签: java spring active-directory ldap hex