Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring passport-ldap

Trying to use this package: https://www.npmjs.com/package/passport-ldapauth

I managed to find the ldap-settings for my company in a medawikiserver (php)

$wgLDAPDomainNames               = array("COMPANY");
$wgLDAPGroupBaseDNs              = array("COMPANY"=>"dc=company,dc=se");
$wgLDAPAutoAuthDomain            = "COMPANY";
$wgLDAPGroupUseFullDN            = array("COMPANY"=>true );
$wgLDAPServerNames               = array("COMPANY"=>"dcst.company.se");
$wgLDAPSearchStrings             = array("COMPANY" => "COMPANY\\USER-NAME" );
$wgLDAPSearchAttributes          = array("COMPANY"=>"sAMAccountName");
$wgLDAPBaseDNs                   = array("COMPANY"=>"dc=company,dc=se");
$wgLDAPEncryptionType            = array("COMPANY" => "ssl" );
$wgMinimalPasswordLength         = 1;

I need to map this to the node-package. I tried this:

var opts = {
  server: {
    url: 'ldaps://dcst.company.se',
    bindDn: 'dc=company,dc=se',
    //bindCredentials: 'secret',
    searchBase: 'dc=company,dc=se',
    searchFilter: '(&(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{username}})))',
    searchAttributes: ['displayName', 'mail'],
  }
};

I get "Bad request". This is from the docs:

badRequestMessage flash message for missing username/password (default: 'Missing credentials')

What have I done wrong?

like image 231
Joe Avatar asked Sep 28 '15 15:09

Joe


1 Answers

You need to add the admin credentials. Here's how my configuration works:

var Strategy = require('passport-ldapauth').Strategy
  , passport = require('passport')
  , config = require('config')
  , userLookup = require('./userLookup');

var ldapConfig = {
  server: {
    url: config.get('ldap.url'),
    adminDn: config.get('ldap.adminDn'),
    adminPassword: config.get('ldap.adminPassword'),
    searchBase: config.get('ldap.searchBase'),
    searchFilter: config.get('ldap.searchFilter')
  }
};

passport.use('ldap', new Strategy(ldapConfig, userLookup));
like image 113
Dan Crews Avatar answered Oct 07 '22 19:10

Dan Crews