I am using the "activedirectory" package to get User's information from the Active Directory but I need to get more the User's Manager information too...
The code the I use is:
var ActiveDirectory = require('activedirectory');
var ad = new ActiveDirectory('ldap://mydomain.com', 'dc=mydomain, dc=com', '[email protected]', 'dragon');
var query = 'cn=JohnS';
ad.findUsers(query, true, function(err, users) {
if (err) {
console.log('ERROR: ' +JSON.stringify(err));
return;
}
if ((! users) || (users.length == 0)) console.log('No users found.');
else {
console.log('findUsers: '+JSON.stringify(users));
}
});
And what I get in return is:
[
{
"dn": "CN=JohnS,OU=NorthWall,DC=mydomain,DC=com",
"userPrincipalName": "[email protected]",
"sAMAccountName": "JohnS",
"whenCreated": "20160315093421.0Z",
"pwdLastSet": "131123123123467132",
"userAccountControl": "66048",
"givenName": "JohnS",
"cn": "JohnS",
"displayName": "busterd",
"groups": []
}
]
I would like to get the specific manager of the user information too.
Thanks in advance, Max.
By default, the manager attribute is not included in the output and you need to create your ActiveDirectory instance as
var ad = new ActiveDirectory(...,
attributes: {
user: [ 'dn', 'userPrinicipalName', ..., 'manager' ]
});
Note: if overriding the 'user' or 'group' attribute, you must specify ALL of the attributes you want, i.e. if you want to keep all attributes that are currently returned - include them in user: [ ]
.
A manager attribute is typically has a DN value referred to another user and depends on your requirements, you might either need to parse it (e.g. to extract sAMAccountName out of it) or call the findUser() method to get a full name and other attributes of the manager.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments