Closed jrgleason closed 7 years ago
I am trying to do a simple list of all users on a local apacheDS. My code is like this...
var LDAP = require('ldap-client'); var connect = function(){ ldap.bind({ binddn: 'uid=admin,ou=system', password: 'secret' }, function(err) { search(); }); } var search = function(){ var search_options = { base: "ou=system", scope: LDAP.SUBTREE, filter: '(objectclass=person)' } // connected and ready ldap.search(search_options, function(err, data){ if(data == null || data.length === 0) return console.log("Nothing found"); for(var i = 0; i < data.length; i++){ console.log(data[i].cn); } }); } var ldap = new LDAP({ uri: 'ldap://localhost:10389', // string connect: connect }, function(err) { console.log(JSON.stringify(ldap)); });
The problem is when I run this I get TypeError: Cannot read property 'bind' of undefined. When I change things a little I can get things working...
TypeError: Cannot read property 'bind' of undefined
var ldap = new LDAP({ uri: 'ldap://localhost:10389', // string }, function(err) { console.log(JSON.stringify(ldap)); connect(); });
So can I just not use the connect attribute of LDAP? Do I need to use this instead of ldap?
this
ldap
The callback doesn't currently run in nextTick() on the initial callback (though it arguably should)... Use this instead. I'll update the docs.
nextTick()
I am trying to do a simple list of all users on a local apacheDS. My code is like this...
The problem is when I run this I get
TypeError: Cannot read property 'bind' of undefined
. When I change things a little I can get things working...So can I just not use the connect attribute of LDAP? Do I need to use
this
instead ofldap
?