Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
extract atrributes of all active directory users

I want to extract certain attributes (such as email, phone, etc.) of an active directory users using Node JS. According to this documentation, I was able to extract the attributes of a certain user using this piece of code:

var ActiveDirectory = require('activedirectory');

    var ad = new ActiveDirectory({ url: 'ldap://domain.com',
                               baseDN: 'dc=domain,dc=com',
                               username: 'user@domain.com',
                               password: 'password',
                               attributes: {
                                 user: [ 'givenName', 'mail', 'mobile' ],
                                //  group: [ 'anotherCustomAttribute', 'objectCategory' ]
                               }
                              });

    var sAMAccountName = 'desiredUsername';

    ad.findUser(sAMAccountName, function(err, user) {
        if (err) {
          console.log('ERROR: ' +JSON.stringify(err));
          return;
        }
       
        if (! user) console.log('User: ' + sAMAccountName + ' not found.');
        else console.log(JSON.stringify(user));
    });

Now I want to know how I can extract the desired attributes of all active directory users, considering the fact that some users don't have a groupName.

Is it possible to extract all existing sAMAccountName in the active directory and extract the attributes of each user this way?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use findUsers instead of findUser.

Don't include a filter, and it'll use the default filter of finding all users:

ad.findUsers(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));
  }
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!