activedirectory
Advanced tools
Comparing version 0.6.8 to 0.7.0
{ | ||
"author": "George Heeres <gheeres@gmail.com>", | ||
"name": "activedirectory", | ||
"version": "0.6.8", | ||
"version": "0.7.0", | ||
"description": "ActiveDirectory is an ldapjs client for authN (authentication) and authZ (authorization) for Microsoft Active Directory with range retrieval support for large Active Directory installations.", | ||
@@ -30,3 +30,6 @@ "main": "index.js", | ||
}, | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"mocha": "^2.2.5" | ||
} | ||
} |
267
README.md
@@ -35,149 +35,11 @@ ActiveDirectory for Node | ||
var ActiveDirectory = require('activedirectory'); | ||
var ad = new ActiveDirectory(url, baseDN, username, password); | ||
var config = { url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password' } | ||
var ad = new ActiveDirectory(config); | ||
``` | ||
Optionally the configuration can be specified with an object: | ||
```js | ||
var ActiveDirectory = require('activedirectory'); | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password' }); | ||
``` | ||
The username and password specified in the configuration are what are used for user and group lookup operations. | ||
__Attributes__ | ||
By default, the following attributes are returned for users and groups: | ||
* user - userPrincipalName, sAMAccountName, mail, lockoutTime, whenCreated, pwdLastSet, userAccountControl, employeeID, sn, givenName, initials, cn, displayName, comment, description | ||
* group - objectCategory, distinguishedName, cn, description, member | ||
If you need to override those defaults, then you can override them when you create your ActiveDirectory instance: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { | ||
user: [ 'myCustomAttribute', 'mail', 'userPrinicipalName' ], | ||
group: [ 'anotherCustomAttribute', 'objectCategory' ] | ||
} | ||
}); | ||
``` | ||
or | ||
```js | ||
var ad = new ActiveDirectory(url, baseDN, username, password, { | ||
attributes: { | ||
user: [ 'myCustomAttribute', 'mail', 'userPrinicipalName' ], | ||
group: [ 'anotherCustomAttribute', 'objectCategory' ] } | ||
}); | ||
``` | ||
If overriding the 'user' or 'group' attribute, you must specify ALL of the attributes you want. The existing defaults | ||
will be overridden. Optionally, you can override the attributes on a per call basis using the 'opts' parameter. | ||
__Referrals__ | ||
By default, referral chasing is disabled. To enable it, specify a referrals attribute when you create your instance. | ||
The referrals object has the following syntax: | ||
```js | ||
{ | ||
referrals: { | ||
enabled: false, | ||
excluded: [ | ||
'ldaps?://ForestDnsZones\./.*', | ||
'ldaps?://DomainDnsZones\./.*', | ||
'ldaps?://.*/CN=Configuration,.*' | ||
] | ||
} | ||
} | ||
``` | ||
The 'excluded' options is a list of regular expression filters to ignore specific referrals. The default exclusion list | ||
is included above, ignoring the special partitions that ActiveDirectory creates by default. To specify these options, | ||
override them as follows: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { ... }, | ||
referrals: { | ||
enabled: true, | ||
excluded: [ ] | ||
} | ||
}); | ||
``` | ||
or | ||
```js | ||
var ad = new ActiveDirectory(url, baseDN, username, password, { | ||
attributes: { ... }, | ||
referrals: { enabled: true } | ||
}); | ||
``` | ||
If you enable referral chasing, the specified username MUST be a userPrincipalName. | ||
__Custom entry parsing __ | ||
if you want to manipulate the search entry in a different way or perhaps augment the search | ||
result with additional data, you can pass a custom parser. This is useful, for example, in case | ||
you want to change the objectSid or GUID which are binary values. | ||
Example: | ||
```js | ||
function customEntryParser(entry, raw, callback){ | ||
if (raw.hasOwnProperty("objectSid")){ | ||
entry.objectSid = raw.objectSid; | ||
} | ||
if (raw.hasOwnProperty("objectGUID")){ | ||
entry.objectGUID = raw.objectGUID; | ||
} | ||
callback(entry); | ||
}; | ||
``` | ||
If you want to specify your own parser you can override the default parser as follows: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { ... }, | ||
referrals: { ... }, | ||
entryParser : customEntryParser | ||
}); | ||
``` | ||
or | ||
```js | ||
var ad = new ActiveDirectory(url, baseDN, username, password, { | ||
attributes: { ... }, | ||
referrals: { ... }, | ||
entryParser : customEntryParser | ||
}); | ||
``` | ||
Optionally, you can specify your custom entry parser as part of the 'opts' object. See [optional parameters](#opts) | ||
for more information. | ||
```js | ||
var opts = function(entry, raw, callback) { | ||
entry.retrievedAt = new Date(); | ||
callback(entry); | ||
}; | ||
ad.findUser(opts, 'userPrincipalName=bob@domain.com', function(err, user) { | ||
... | ||
}); | ||
``` | ||
--------------------------------------- | ||
Documentation | ||
@@ -427,2 +289,3 @@ -------------- | ||
```js | ||
var _ = require('underscore'); | ||
var query = 'cn=*Exchange*'; | ||
@@ -436,3 +299,3 @@ var opts = { | ||
ad.find(query, function(err, results) { | ||
if ((err) || (! result)) { | ||
if ((err) || (! results)) { | ||
console.log('ERROR: ' + JSON.stringify(err)); | ||
@@ -443,3 +306,3 @@ return; | ||
console.log('Groups'); | ||
_.each(result.groups, function(group) { | ||
_.each(results.groups, function(group) { | ||
console.log(' ' + group.cn); | ||
@@ -449,3 +312,3 @@ }); | ||
console.log('Users'); | ||
_.each(result.users, function(user) { | ||
_.each(results.users, function(user) { | ||
console.log(' ' + user.cn); | ||
@@ -455,3 +318,3 @@ }); | ||
console.log('Other'); | ||
_.each(result.other, function(other) { | ||
_.each(results.other, function(other) { | ||
console.log(' ' + other.cn); | ||
@@ -673,3 +536,111 @@ }); | ||
--------------------------------------- | ||
## Advanced Usage | ||
### Attributes | ||
By default, the following attributes are returned for users and groups: | ||
* user - distinguishedName, userPrincipalName, sAMAccountName, mail, lockoutTime, whenCreated, pwdLastSet, userAccountControl, employeeID, sn, givenName, initials, cn, displayName, comment, description | ||
* group - distinguishedName, objectCategory, cn, description | ||
If you need to override those defaults, then you can override them when you create your ActiveDirectory instance: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { | ||
user: [ 'myCustomAttribute', 'mail', 'userPrinicipalName' ], | ||
group: [ 'anotherCustomAttribute', 'objectCategory' ] | ||
} | ||
}); | ||
``` | ||
If overriding the 'user' or 'group' attribute, you must specify ALL of the attributes you want. The existing defaults | ||
will be overridden. Optionally, you can override the attributes on a per call basis using the 'opts' parameter. | ||
### Referrals | ||
By default, referral chasing is disabled. To enable it, specify a referrals attribute when you create your instance. | ||
The referrals object has the following syntax: | ||
```js | ||
{ | ||
referrals: { | ||
enabled: false, | ||
excluded: [ | ||
'ldaps?://ForestDnsZones\./.*', | ||
'ldaps?://DomainDnsZones\./.*', | ||
'ldaps?://.*/CN=Configuration,.*' | ||
] | ||
} | ||
} | ||
``` | ||
The 'excluded' options is a list of regular expression filters to ignore specific referrals. The default exclusion list | ||
is included above, ignoring the special partitions that ActiveDirectory creates by default. To specify these options, | ||
override them as follows: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { ... }, | ||
referrals: { | ||
enabled: true, | ||
excluded: [ ] | ||
} | ||
}); | ||
``` | ||
If you enable referral chasing, the specified username MUST be a userPrincipalName. | ||
### Custom Entry Parsing | ||
if you want to manipulate the search entry in a different way or perhaps augment the search | ||
result with additional data, you can pass a custom parser. This is useful, for example, in case | ||
you want to change the objectSid or GUID which are binary values. | ||
Example: | ||
```js | ||
function customEntryParser(entry, raw, callback){ | ||
if (raw.hasOwnProperty("objectSid")){ | ||
entry.objectSid = raw.objectSid; | ||
} | ||
if (raw.hasOwnProperty("objectGUID")){ | ||
entry.objectGUID = raw.objectGUID; | ||
} | ||
callback(entry); | ||
}; | ||
``` | ||
If you want to specify your own parser you can override the default parser as follows: | ||
```js | ||
var ad = new ActiveDirectory({ url: 'ldap://dc.domain.com', | ||
baseDN: 'dc=domain,dc=com', | ||
username: 'username@domain.com', | ||
password: 'password', | ||
attributes: { ... }, | ||
referrals: { ... }, | ||
entryParser : customEntryParser | ||
}); | ||
``` | ||
Optionally, you can specify your custom entry parser as part of the 'opts' object. See [optional parameters](#opts) | ||
for more information. | ||
```js | ||
var opts = function(entry, raw, callback) { | ||
entry.retrievedAt = new Date(); | ||
callback(entry); | ||
}; | ||
ad.findUser(opts, 'userPrincipalName=bob@domain.com', function(err, user) { | ||
... | ||
}); | ||
``` | ||
<a name="opts" /> | ||
@@ -726,4 +697,6 @@ ### Optional Parameters / Extended Functionality | ||
------------------------------------------------ | ||
[underscore]: http://underscorejs.org/ | ||
[async]: https://github.com/caolan/async | ||
[ldapjs]: http://ldapjs.org/ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150826
25
3268
1
695