node-activedirectory icon indicating copy to clipboard operation
node-activedirectory copied to clipboard

Authentication with "domain\username"

Open juracyjunior opened this issue 7 years ago • 3 comments

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!');
  }
});

juracyjunior avatar May 18 '17 19:05 juracyjunior

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 avatar Jun 29 '17 11:06 audhen

@audhen as a suggestion I let the component could have a setting to determine a default domain. Would not that be cool?

juracyjunior avatar Dec 06 '17 01:12 juracyjunior

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...

AMMullan avatar Dec 15 '17 18:12 AMMullan