passport-activedirectory
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -56,3 +56,3 @@ 'use strict'; | ||
this._ad = new ActiveDirectory(options.ldap); | ||
this._ad = typeof options.ldap === 'function' ? options.ldap : new ActiveDirectory(options.ldap); | ||
} | ||
@@ -59,0 +59,0 @@ |
{ | ||
"name": "passport-activedirectory", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Active Directory strategy for passport.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -27,3 +27,3 @@ # passport-activedirectory | ||
}, function (profile, ad, done) { | ||
ad.isMemberOf(profile._json.dn, 'AccessGroup', function (err, isMember) { | ||
ad.isUserMemberOf(profile._json.dn, 'AccessGroup', function (err, isMember) { | ||
if (err) return done(err) | ||
@@ -48,2 +48,27 @@ return done(null, profile) | ||
#### Optionally reuse an existing instance of `activedirectory` | ||
``` | ||
var passport = require('passport') | ||
var ActiveDirectoryStrategy = require('passport-activedirectory') | ||
var ActiveDirectory = require('activedirectory') | ||
var ad = new ActiveDirectory({ | ||
url: 'ldap://my.domain.com', | ||
baseDN: 'DC=my,DC=domain,DC=com', | ||
username: 'readuser@my.domain.com', | ||
password: 'readuserspassword' | ||
}) | ||
passport.use(new ActiveDirectoryStrategy({ | ||
integrated: false, | ||
ldap: ad | ||
}, function (profile, ad, done) { | ||
ad.isUserMemberOf(profile._json.dn, 'AccessGroup', function (err, isMember) { | ||
if (err) return done(err) | ||
return done(null, profile) | ||
}) | ||
})) | ||
``` | ||
### API | ||
@@ -59,3 +84,3 @@ | ||
* [`mapProfile`] { `Function` } - Custom profile mapping function. Takes user object as only parameter and returns a profile object. `_json` is added to the object with the full object | ||
* [`ldap`] { `Object` } - LDAP connection object. Extended properties are documented [here](https://github.com/gheeres/node-activedirectory#optional-parameters--extended-functionality) | ||
* [`ldap`] { `Object` | `ActiveDirectory` } - LDAP connection object. Extended properties are documented [here](https://github.com/gheeres/node-activedirectory#optional-parameters--extended-functionality). You may also supply an instance of `activedirectory` instead. | ||
* `url` { `String` } - LDAP URL (e.g. `ldap://my.domain.com`) | ||
@@ -62,0 +87,0 @@ * `baseDN` { `String` } - Base LDAP DN to search for users in |
11180
105