Skip to content

Instantly share code, notes, and snippets.

@pvencill
Last active January 19, 2023 04:44
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save pvencill/97565feede746b12ff52 to your computer and use it in GitHub Desktop.
Save pvencill/97565feede746b12ff52 to your computer and use it in GitHub Desktop.
Creating a new user in LDAPjs; complete example.
var ldap = require('ldapjs');
var ssha = require('node-ssha256');
var BASE = 'ou=Users,dc=example,dc=org';
// default port for ldaps
var URL = 'ldaps://ldap.example.org/:636';
// user and pass are for existing user with rights to add a user
function myLDAPBind(user, pass, callback) {
var client = ldap.createClient({
url: URL
});
var newDN = "cn=new guy,ou=Users,dc=example,dc=org";
var newUser = {
cn: 'new guy',
sn: 'guy',
uid: 'nguy',
mail: 'nguy@example.org',
objectClass: 'inetOrgPerson',
userPassword: ssha.create('s00prs3cr3+')
}
client.bind(user,pass,function(err){
client.add(newDN, newUser, callback);
});
}
@DawnMD
Copy link

DawnMD commented Dec 10, 2020

userPassword: ssha.create('s00prs3cr3+')

This ssha password still shows as 'clear' on phpLDAPadmin.
any workaround for that ?

@qeba
Copy link

qeba commented Jan 19, 2023

Anyone need help, any workaround for this userPassword: ssha.create('s00prs3cr3+') like maybe used sha256 to store the password? any example for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment