!!! Overview This is a simple [Java] [Example] of how to set the [Simple Password] for [EDirectory]. {{{ package com.willeke.ldap.novell.simplepasswords; /** * <p>Title: </p> * <p>Description: Program changes the eDirectory Simplepassword</p> * * <p>Copyright: Copyright (c) 2003</p> * <p>Company: WILLEKE.COM</p> * @author Jim Willeke * @version 1.0 */ import org.apache.log4j.*; import com.novell.ldap.*; public class SPManager { private static final String JAVA_HOME = System.getProperty("java.home"); static Logger logger = Logger.getLogger("SPManager"); private static final String currentPath = System.getProperty("user.dir"); public SPManager() { BasicConfigurator.configure(); PropertyConfigurator.configure(currentPath + "\\logger.properties"); logger.info("Application: " + this.getClass().toString() + " Started by: " + System.getProperty("user.name")); } /** * <p> This program will set the simplepassword to the value as passed. * This is a static method to be called by another method. * You will need to set the LDAP Control when you create the LDAPConnection * Object. Somthing like this should do it:</p> * <p> * private static final String LDAP_SIMPLE_PASS ="2.16.840.1.113719.1.27.101.5"; * // Create a LDAPControl object - Set this to critical so if we Fail we do not set userPassword to the SHA value * LDAPControl pwdControl = new LDAPControl(LDAP_SIMPLE_PASS, true, null); * logger.debug("Control OID: " + LDAP_SIMPLE_PASS); * // Set the LDAP control to be sent as part of modify request * LDAPConstraints cons = lc.getConstraints(); * cons.setControls(pwdControl); * lc.setConstraints(cons);</p> * @param lc - LDAP Connection with control set * @param entryDN - entry to change password for * @param value - password in properformat "(ie.{SHA}0ae93qPRvOSSCAq1m7Uy+egycGk=) */ public static void spWrite(LDAPConnection lc, String entryDN, String value) { if(lc.isBound()) { logger.debug("Service Account DN: " + lc.getAuthenticationDN()); logger.debug("LDAP Server/Port: " + lc.getHost() + "/" + lc.getPort()); logger.debug("Attempting change on entry: " + entryDN); logger.debug("Password value: " + value); // Create LDAPModification Array LDAPModification[] modifications = new LDAPModification[1]; try { //Create Attribute for userPassword LDAPAttribute addPassword = new LDAPAttribute("userPassword", value); // NOTE: You may want to do a replace as this is an add. // You can set multiple simplepasswords modifications[0] = new LDAPModification(LDAPModification.ADD, addPassword); lc.modify(entryDN, modifications); logger.debug("Password Successfully modified for: " + entryDN); // disconnect with the server ??? lc.disconnect(); } catch(LDAPException e) { if(e.getResultCode() == LDAPException.NO_SUCH_OBJECT) { logger.error("SimplePassword Change Failed: No such entry: " + entryDN); } else { logger.error("Error: on: " + entryDN + " :" + e.toString()); } } } else { // We have no Authenticated connection logger.fatal("No Authenticated LDAPConnection!"); } } /** * Used for testing * @param args */ public static void main(String[] args) { SPManager spMgr = new SPManager(); LDAPConnection ldc = new LDAPConnection(); try { ldc = com.willeke.ldap.pools.LDAPConnWrapper.instance().getConnection(true); } catch(Exception ex) { logger.error(ex); } spWrite(ldc, "uid=pwdtest,ou=people,dc=willeke,dc=com", "{SHA}0ae93qPRvOSSCAq1m7Uy+egycGk="); } } }}}!! More Information There might be more information for this subject on one of the following: [{ReferringPagesPlugin before='*' after='\n' }]