node.jsldapldapjs

How Do I Assign LDAP Password Via LDAPjs?


I'm using ldapjs.

I got this code from some sites:

var newUser = {
    cn: 'new guy',
    sn: 'guy',
    uid: 'nguy',
    mail: 'nguy@example.org',
    objectClass: 'inetOrgPerson',
    userPassword: ssha.create('s00prs3cr3+')
}

The thing is, the password saved as OctetString, and can't be used for login. Do anyone here knows how do I assign password using node (ldapjs preferred)?


Solution

  • Try saving in plain text.

    Most LDAP server implementations expect to receive the password in plain text and the server will then encrypt the password.

    There are dependencies on the LDAP server implementation and configuration.

    -jim

    Oh, You did not mention it was AD. Active directory is quite different. It uses [unicodePwd][1], not userPassword. Password operations must be over an encrypted connection. And finally, the password must be "text value in UTF-16". Those Quotes are required.

    See updateUserPassword for the JNDI (Java) code for this.