how to properly authenticate Node.js app using activedirectory / ldapjs module?

683
January 20, 2018, at 05:16 AM

I need to authenticate my Node.js app against Active Directory. I've found the following node module to do that:

https://github.com/gheeres/node-activedirectory

I'm using this free AD service: http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

My code looks like this:

var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://ldap.forumsys.com',
    baseDN: 'dc=forumsys,dc=com',
    username: 'tesla@forumsys.com',
    password: 'password' };
var ad = new ActiveDirectory(config);
var username = 'tesla';
var password = 'password';
ad.authenticate(username, password, function(err, auth) {
    if (err) {
        console.log('ERROR: '+JSON.stringify(err));
        return;
    }
    if (auth) {
        console.log('Authenticated!');
    }
    else {
        console.log('Authentication failed!');
    }
});

The error I'm getting is: ERROR: {"lde_message":"invalid DN","lde_dn":null}

What can I do to make this work?

Answer 1
var config = { url: 'ldap://ldap.forumsys.com',
    baseDN: 'dc=forumsys,dc=com',
    username: 'tesla@forumsys.com',
    password: 'password' };
ERROR: {"lde_message":"invalid DN","lde_dn":null}

At first glance the error seems to point that you're supposed to change those values in the config object to match your local environment/active directory.

READ ALSO
Initiate data transfers from Server => Client?

Initiate data transfers from Server => Client?

i want to build a server app in node/express which receives requests from one client and sends information to another client, maybe somehow similar to this:

173
How to use information from 4sq node module lat long into geocoder module

How to use information from 4sq node module lat long into geocoder module

How do I use the information that I receive from foursq node module (lat long) and use it into geocoder node module using promisesI am trying to do a reverse search with lat long

171
NodeJS measure an execution time that takes at least 10 microseconds

NodeJS measure an execution time that takes at least 10 microseconds

In my computer the below code takes 60-70 microseconds

185
Can't connect to Node server on Amazon EC2

Can't connect to Node server on Amazon EC2

Here's the appjs, the code is too long so that's why I'm showing this code only, there's no problem in other code I assume this is a network problem

188