node.js - How the get "Manager" property from ActiveDirectory with NodeJS? -


i using "activedirectory" package user's information active directory need more user's manager information too...

the code use is:

var activedirectory = require('activedirectory'); var ad = new activedirectory('ldap://mydomain.com', 'dc=mydomain, dc=com', 'dragon@mydomain.com', '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 in return is:

[    {       "dn": "cn=johns,ou=northwall,dc=mydomain,dc=com",       "userprincipalname": "johns@mydomain.com",       "samaccountname": "johns",       "whencreated": "20160315093421.0z",       "pwdlastset": "131123123123467132",       "useraccountcontrol": "66048",       "givenname": "johns",       "cn": "johns",       "displayname": "busterd",       "groups": []    } ] 

i specific manager of user information too.

thanks in advance, max.

by default, manager attribute is not included in output , need create activedirectory instance

var ad = new activedirectory(...,              attributes: {                  user: [ 'dn', 'userprinicipalname', ..., 'manager' ]              }); 

note: if overriding 'user' or 'group' attribute, must specify of attributes want, i.e. if want keep attributes returned - include them in user: [ ].

a manager attribute typically has dn value referred user , depends on requirements, might either need parse (e.g. extract samaccountname out of it) or call finduser() method full name , other attributes of manager.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -