@ Override public boolean setUserAsUser ( Node node , String uid , String password ) throws Exception { boolean status = false ; StringBuilder sb = new StringBuilder ( userIdentifyer + "=" ) . append ( uid ) . append ( "," ) ; sb . append ( Configuration . getProperty ( instanceName + LdapKeys . ATTR_OU_PEOPLE ) ) . append ( "," ) ; sb . append ( baseDn ) ; if ( uid == null || uid . isEmpty ( ) || password == null || password . isEmpty ( ) ) { return false ; } try { Hashtable < String , String > environment = ( Hashtable < String , String > ) ctx . getEnvironment ( ) . clone ( ) ; environment . put ( Context . SECURITY_PRINCIPAL , sb . toString ( ) ) ; environment . put ( Context . SECURITY_CREDENTIALS , password ) ; DirContext dirContext = new InitialDirContext ( environment ) ; status = setUserInContext ( dirContext , node ) ; dirContext . close ( ) ; } catch ( NamingException ex ) { handleNamingException ( "NamingException " + ex . getLocalizedMessage ( ) , ex ) ; } return status ; }
Writes the modifications on an user object back to the LDAP using a specific context .