Closed webCoderLOL closed 8 years ago
Documentation error :(
Try connect: instead of reconnect:
Thanks for the quick reply. I tried that too but i got
tim-m1:ldap tim$ node ldapClient.js
/Users/tim/apps/ldap/ldapClient.js:9
ldap.bind({
^
TypeError: Cannot read property 'bind' of undefined
at Object.LDAP.connect (/Users/tim/apps/ldap/ldapClient.js:9:7)
at LDAP.onconnect (/Users/tim/apps/ldap/node_modules/ldap-client/index.js:104:25)
at new LDAP (/Users/tim/apps/ldap/node_modules/ldap-client/index.js:99:33)
at Object.<anonymous> (/Users/tim/apps/ldap/ldapClient.js:3:12)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
Can't remember the calling context for that -- what does this.bind() do?
Here is the code that complained ldap.bind()
var LDAP = require('ldap-client');
var ldap = new LDAP({
uri: 'ldap://localLDAP',
base: 'DC=example,DC=com',
scope: LDAP.SUBTREE,
connect: function(){
// bind
ldap.bind({
binddn: 'cn=User,DC=example,DC=com',
password: 'pw'
}, function(err){
if(err)
console.log(err);
// search
ldap.search({
attrs: 'telephoneNumber',
filter: 'employeeNumber=503433'
}, function(err, data){
if(err)
console.log("search error: "+err);
// console.log(JSON.stringify(data, null, 2));
console.log("telephoneNumber: "+data[0].telephoneNumber)
ldap.close();
});
});
}
}, function(err){
if(err)
console.log(err);
});
Right, try replacing ldap.bind() in the connect function to be this.bind()
Good point. I tried that too.
TypeError: this.bind is not a function
Fixed in 3.1.3 Sorry for the long delay.
README example still refers to ldap.bind instead of this.bind
I have problem to understand the reconnect function. I looked at the index.js but saw no one is calling it. I think I must miss something. Therefore, I couldn't get my code working as following:
================= NOT WORKING =================================
However, the following code is working
===================== Awesome =====================