0
我添加了具有由获取LDAP属性,它包含一个属性对象
BasicAttributes basicAttributes = new BasicAttributes();
BasicAttribute basicAttribute = new BasicAttribute("objectclass");
basicAttribute.add("top");
basicAttribute.add("Adapter");
basicAttributes.put(basicAttribute);
basicAttributes.put(new BasicAttribute("Name","testname"));
basicAttributes.put(new BasicAttribute("Topic", "testtopic"));
if (locid.length != 0) {
basicAttribute = new BasicAttribute("LocID");
for (int i = 0; i < locationid.length; i++)
basicAttribute.add(locationid[i]);
basicAttributes.put(basicAttribute);
}
basicAttributes.put(new BasicAttribute("Password", "passw"));
给出一个属性的LDAP条目现在的密码属性是SHA哈希密码。
但当我检索使用ctx.getAttributes这样
Attributes result = ctx.getAttributes(dn);
NamingEnumeration<?> nm = result.getAll();
while (nm.hasMore()) {
Attribute at = (Attribute) nm.next();
System.out.println(nm.next());
}
}
属性我得到的输出是
Password: [[email protected]
Name: testname
Topic: testtopic
LocID:
objectClass: top, Adapter
cn: test1234
我怎样才能重新contruct的密码为String变量?
编辑:我想这
while (nm.hasMore()) {
Attribute at = (Attribute) nm.next();
if (at.getID().equals("Password"))
{
byte [] a = (byte[])at.get();
String b = new String(a);
System.out.println(b);
}
}
现在打印此 - {SSHA} AvvOJFnG2tjwNTGtDzDnubC/b2B1FbzP5S/LSQ ==
现在我怎么得到它仅打印 “PASSW” - 原始密码。
感谢您的信息。我想向正在查看LDAP条目的用户显示密码。所以我要去查它。此外,LDAP中的条目具有SHA哈希密码的密码属性。但是,当我添加一个具有上述密码属性的新条目时,密码将变为SSHA散列密码。你可以从我上面写的价值中看到。它就像'{SSHA}'。这是由于Salt的价值增加了。但是我不知道这个过程中价值的增加。你能告诉我一些吗? – v1shnu 2015-03-04 04:33:14