Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 676
DevOps85 Avatar asked Jul 23 '26 21:07

DevOps85


1 Answers

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);
like image 171
Alex Avatar answered Jul 26 '26 12:07

Alex