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?
Objectis it? It's not likely it'sjava.lang.Object. You should find out what kind ofObjectit really is and cast it to that type.getObjectAttribute("userPassword")returns you anObject, that sound's right. If you have a debugger see what kind of object it is, or if not,System.out.println(theObject.getClass().getName())to find out what kind ofObjectit is. Once you know, just cast it to the right type.byte[]array, so try this:String pwHash = new String((byte[]) theObject);, this is casting theObjectto abyte[]array and creating a newStringfrom it (using the default encoding)