Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda