How the get "Manager" property from ActiveDirectory with NodeJS?

MaxBk

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.

user2316116

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get current token from Azure ActiveDirectory application

From Dev

How to get current token from Azure ActiveDirectory application

From Dev

How do I get a custom property to appear in the property manager?

From Dev

How to "get" from NodeJS with AngularJS

From Dev

How to get a property from another property in JS?

From Dev

How to get property from ofono

From Dev

How to get a property from a plist

From Dev

How to get a property from a plist

From Dev

How to get users without subgroups in ActiveDirectory?

From Dev

How to get the values from json object in nodejs

From Dev

How to get variable from request in nodejs module

From Dev

How to get data from XML parser in nodeJS

From Dev

How to get data from request Nodejs

From Dev

How to get translate property from a group?

From Dev

How to get property info from Powershell object?

From Dev

how to get to parent overridden property from child?

From Dev

How to get property name from expression

From Dev

How to get property from component when testing?

From Dev

How to get property from an array of object ?

From Dev

How to get value from property in BeanShell (jmeter)

From Dev

How to get Property value from a Javascript object

From Dev

How to get annotations of a Kotlin property from Java?

From Dev

how to get to parent overridden property from child?

From Dev

How to get property name from expression

From Dev

How to get property information from a class

From Dev

How get response from resolve property in routeProvider?

From Dev

How to get property from an array of object ?

From Dev

How to get object with largest property from array?

From Dev

How to get property info from Powershell object?

Related Related

HotTag

Archive