DevOps85
DevOps85

Reputation: 6523

How get userPassword attribute from LDAP using Spring and Java

i want to get userPassword attribute from ldap using spring in java.

of course this not work:

context.getStringAttribute("userPassword");

If i try:

context.getObjectAttribute("userPassword");

i can get this attribute..but now from Object how i can get the hash password?

Upvotes: 3

Views: 7054

Answers (1)

Alex
Alex

Reputation: 2485

It sounds like context.getObjectAttribute("userPassword") returns an Object so you just need to identify what it is.

Based on the comments it was a byte[] array which was representing a String, so you can basically do this:

Object o = context.getObjectAttribute("userPassword");
byte[] bytes = (byte[]) o;
String hash = new String(bytes);

Upvotes: 5

Related Questions