0

I'm developing a simple node app using ldapjs. Unfortunately, I'm not sure how to make the connection with ldap.

Our IT department gave me the below credentials (some redacted for security). enter image description here

My app.js file looks like the following. I just need to retrieve a user's data (given a username and password).

var ldap = require('ldapjs');

var client = ldap.createClient({
  url: 'ldap://xx.xxx.xxx.xxxx/dc=xxxxx,dc=org'
});

var opts = {
  filter: '(objectclass=user)',
  scope: 'sub',
  attributes: ['objectGUID']
};

client.bind('xx@xxxx.org', 'xxxx', function (err) {
  console.log("Logging data...");
  client.search('dc=xxxx,dc=org', function (err, search) {
    search.on('searchEntry', function (entry) {
      var user = entry.object;
      console.log(user.objectGUID);
    });
  });
});

Any help is greatly appreciated. Thanks.

Viper
  • 1,327
  • 2
  • 12
  • 33
  • Do you get any output to standard out? does `Logging data...` print? – Hurricane Hamilton Dec 07 '15 at 19:05
  • Yes, it does. I'm not getting anything returned. – Viper Dec 07 '15 at 20:48
  • I would add more logging. Add console.logs as the first statements in the client.search callback and the search.on callback. That will help narrow down where exactly the issue occurs. – Hurricane Hamilton Dec 07 '15 at 21:06
  • Ok. Honestly, it's my first time working with ldap. Does my code look right? – Viper Dec 08 '15 at 16:54
  • Here's the error I'm now getting: Error: connect ETIMEDOUT at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19) MacBook-Pro:node User$ node app.js events.js:85 throw er; // Unhandled 'error' event – Viper Dec 08 '15 at 17:00
  • I haven't used the specific LDAP library you are using, but at first glance the code looks reasonable. However, if you are getting a timeout error, that means that the LDAP module can't even connect to your ldap server. I would double check the ip address of the server you are connecting to, and do an nmap on it from your local machine to make sure the ports are open. – Hurricane Hamilton Dec 10 '15 at 13:51

0 Answers0