Last active
January 19, 2023 04:44
-
-
Save pvencill/97565feede746b12ff52 to your computer and use it in GitHub Desktop.
Creating a new user in LDAPjs; complete example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '[email protected]', | |
objectClass: 'inetOrgPerson', | |
userPassword: ssha.create('s00prs3cr3+') | |
} | |
client.bind(user,pass,function(err){ | |
client.add(newDN, newUser, callback); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyone need help, any workaround for this
userPassword: ssha.create('s00prs3cr3+')
like maybe used sha256 to store the password? any example for that?