node-activedirectory
node-activedirectory copied to clipboard
Authentication with "domain\username"
How do I authenticate user using "domain\user", as shown in the example below? I can only care if the user has the "domain.com".
var ActiveDirectory = require('activedirectory');
var config = {
url: 'ldap://ldaps.domain.com',
baseDN: 'dc=domain,dc=com'
}
var ad = new ActiveDirectory(config);
var username = 'domain\username';
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!');
}
});
I'd design my frontend in a way, so that the domain is a) given or b) user selectable from pre-defined options (multi domain environment).
than just concatenate the user with the domain - boom, bob's your uncle! :D
@audhen as a suggestion I let the component could have a setting to determine a default domain. Would not that be cool?
I'm doing the same as you @juracyjunior and your example (same as docs) works fine for me but the problem is that I can't actually then use that same username format anywhere else in in activedirectory and I can't retrieve the dn etc from the authenticate function...