title: How to connect and find a user from Azure AD using Nodejs
body: <p>I am trying to find a user from the azure active directory using nodejs. I am using <a href="https://github.com/gheeres/node-activedirectory#findUser" rel="nofollow noreferrer">Node-ActiveDirectory</a> for this task. First I tried to connect to the Azure active directory as the given example in the <a href="https://github.com/gheeres/node-activedirectory#findUser" rel="nofollow noreferrer">above link</a>. example code as below that I have used.</p>
  
  <pre><code>var ActiveDirectory = require('activedirectory');
  var config = { url: 'ldap://myhotmail.onmicrosoft.com',
      baseDN: 'dc=myhotmail,dc=onmicrosoft,dc=com',
      username: 'roledene@myhotmail.onmicrosoft.com',
      password: 'myPassword'
  }
  var ad = new ActiveDirectory(config);
  
  var username = 'roledene@myhotmail.onmicrosoft.com';
  var password = 'myPassword';
  
  ad.authenticate(username, password, function(err, auth) {
      if (err) {
          console.log('ERROR: '+JSON.stringify(err));
          return;
      }
  
      if (auth) {
          console.log('Authenticated!');
      }
      else {
          console.log('Authentication failed!');
      }
  });
  </code></pre>
  
  <p>but it gives the following error. what is wrong with this code ?</p>
  
  <pre><code>ERROR: {"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo","hostname":"myhotmail.onmicrosoft.com","host":"myhotmail.onmicrosoft.com","port":389}
  </code></pre>