gheeres / node-activedirectory

ActiveDirectory is an Node.js ldapjs client for authN (authentication) and authZ (authorization) for Microsoft Active Directory with range retrieval support for large Active Directory installations.
MIT License
534 stars 146 forks source link

Two searches in one ? #217

Open Cliff-R-K opened 4 years ago

Cliff-R-K commented 4 years ago

Firstly I must admit that I am completly new to active directory and this is my first attempt trying to collect data using ad.

I managed to get a simple example working:

const config = {
  url: "ldap://<url>",
  baseDN: "OU=Users,OU=Default,DC=<dc>,DC=intra,DC=local",
  username: "<user>",
  password: "<pass>"
};

let sAMAccountName = "test";

let ad = new ActiveDirectory(config);
ad.findUser(sAMAccountName, function(err, user) {
  console.log(JSON.stringify(user.displayName));
});;

But then I need to use the variable user.displayName in another search using another baseDN: baseDN: 'OU=Laptops,OU=LmComputers,DC=<dc>,DC=intra,DC=local'

to be able to get the returned users computer-info. What is the preferred way to do this?