2.5 Modifying an Entry's Password

eDirectory has a number of restricts that prevent password modification. The user can have insufficient rights for the following reasons:

Passwords in eDirectory are stored as RSA public and private key pairs. The Novell LDAP server uses the userPassword attribute to generate these key pairs for an LDAP client.

If the user has sufficient rights, the process is similar to modifying any attribute of an entry. For a user to change his or her own password, complete the following steps.

  1. Create two LDAPMod structures for the userPassword attribute.

  2. In the first LDAPMod structure, set the modification operation to LDAP_MOD_DELETE, the modification type to "userPassword", and the value to the current password.

  3. In the second LDAPMod structure, set the modification operation to LDAP_MOD_ADD, the modification type to "userPassword", and the value to the new password.

  4. Add the structures to a NULL-terminated array of LDAPMod structures.

  5. Call ldap_modify_ext_s to modify the specified entry's password.

For sample code that allows a user to change his or her password, see modpass.c

For sample code that allows an administrator to set a password, see setpass.c.

The user can also change the password in one LDAP modification. To change the password in a single operation:

  dn: cn=test,o=org
  changetype: modify
  delete: userpassword
  userpassword: pass
  -
  add: userpassword
  userpassword: password