我有一个 ldap 数据库。我正在使用 inetorgPerson 对象类。在这个类中有 userPassword 属性。userPassword 值是 SHA crypt。我正在使用 javax.naming.directory 包来获取 userPassword 值。但是返回值与 SHA 密码值不同。我怎样才能得到正确的价值?一个简单的代码是:
public ArrayList<String> search(String base, String filter,String[] returningAttributes){
ArrayList<String> result=new ArrayList<String>();
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
ctls.setReturningAttributes(returningAttributes);
NamingEnumeration resultEnum = null;
try {
resultEnum = ctx.search(base, filter, ctls);
while (resultEnum.hasMore()) {
SearchResult res = (SearchResult) resultEnum.next();
// print DN of entry
// System.out.println(res.getNameInNamespace());
// print attributes returned by search
Attributes attrs = res.getAttributes();
NamingEnumeration e = attrs.getAll();
while (e.hasMore()) {
Attribute attr = (Attribute) e.next();
result.add(attr.toString());
}
System.out.println();
}
return result;
} catch (NamingException e) {
}
return null;
}