-
-
Save davistran86/5ad7307fdbf761a36a72b9c7e7beacf2 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