I am able to read the password stored in LDAP via JNDI. But the result is some gibberish characters. So how do i decrypt it?
Below is my code:
public
with ldap we will get data in byte array.if you need to get the original password text use the
following code:
Attribute userPassword = attributes.get("userPassword");
String pwd = new String((byte[]) userPassword.get());
What you're seeing ([B@1cd8669) is Java's way of saying "this is a byte array".
The stored "password" is most likely either a hash of the real password or an encrypted version. Cryptographic hashes are, by definition, non-reversible so you will not be able to see what the user's password is if LDAP stores the hash.
If it's encrypted then if you know the algorithm and the key it's fairly simple to decrypt. BouncyCastle is a great Java crypto library you can use to decrypt the password.
Basically, you need to know exactly what you're looking at, and that will depend on the LDAP setup.