How to connect to LDAP using node js? Kindly help with sample code. I am not able to connect the LDAP as in post Connect LDAP using node JS ; Segmentation fault Error.
I prefer you node-LDAP.
In your application, you can use following structure
var ldap = require('LDAP');
var ldapObj = new ldap({ uri: 'ldap://your_server', version: 3});
//check your connection
ldapObj.open(function(err) {
if (err) {
throw new Error('Connection problem occured!');
}
console.log("Connected to ldap");
});
//Search
search_options = {
base: '',
scope: '',
filter: '',
attrs: ''
}
ldapObj.search(search_options, function(err, data){
if (err) {
throw new Error('Search filed');
} else {
console.log("Search result:" + JSON.stringify(data))
}
});
For more detail on search_options you can refer here
Alternative option node-ldapjs is here