Ldap Operations is a nodejs code to make LDAP operations (search, modify and create)
Install node dependencies (only dependency is the module ldapjs )
npm install
At the current state, there is only support for hard-coded values for the operations
Edit variable user for create operations:
const user = {
objectclass: ['imUser', 'imUserAux', 'top'],
cn: 'ftest',
sn: 'ftest12457',
uid: 'ftest12457',
userPassword: '123456'
}
Use the variable opts to define search operations
var opts = {
filter: '(uid=*)',
scope: 'sub',
attributes: ['uid']
};
Use the variable modifyAttr to define modify/add attributes
const modifyAttr = new ldap.Change({
operation: 'add',
modification: {
cn: 'joe.doe'
}
});
You have to define the correct DN at the functions
client.modify('ou=users,ou=im,ou=br,o=com', add_attribute, (err, res) => {
if (err) throw err
console.log('Status: ' + res);
})
Run the code with the following arguments
node ldapoperations.js <HOSTNAME/IP> <PORT> <DN FOR LOGIN> <PASSWORD> <OPERATION SEARCH/CREATE/MODIFY>
Pull requests are welcome.