Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda