title: nodejs ldap authentication failure
body: <p>I am using the activedirectory npm package for authenticating to the activedirectory in the enterprise. Finding trouble authenticating, whereas I have done this multiple times before in other softwares. </p>
  
  <pre><code>var ActiveDirectory = require('activedirectory');
  var config = { url: 'ldap://&lt;ldap server&gt;:389',
  
              baseDN:'DC=ads,DC=dwdwdw,DC=com',
              bindDN: 'CN=dddd,OU=ServiceAccounts,OU=Process,DC=ads,DC=dwdwdw,DC=com',
              bindCredentials: 'vBAX5y5@',
              includeMembership:['user'],
               referrals: {
                   enabled: false,
                   excluded: [ ]
                 },
                 attributes: {
  
                     user: [ 'sAMAccountName' ],
                     group: [ 'distinguishedName' ]
                   },
                 //filter: '(&amp;(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{mail}})))'
                   //filter: '(&amp;(objectcategory=*)(|(samaccountname={{username}})))'
  
               }
  
  var sAMAccountName = 'sss';
  var password = 'password';
  var username = sAMAccountName;
  ad.authenticate(sAMAccountName, password, function(err, auth) {
    if (err) {
     console.log('ERROR: '+JSON.stringify(err));
     return;
   }
  </code></pre>
  
  <p>when I run this nodejs script, I get the below error : </p>
  
  <blockquote>
    <p>ERROR: {"lde_message":"80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580\u0000","lde_dn":null}</p>
  </blockquote>
  
  <p>Safe to say, I have no idea what I am doing. </p>
  
  <p>But I do know that the searchAttribute should be 'sAMAccountName' - how do i put this in the config?  </p>
  
  <p>I also know that when I substitute the username of 'sss' with its DN i.e. </p>
  
  <pre><code>var username = 'CN=&lt;full name of user&gt;,OU=InfoWorker,OU=People,DC=ads,DC=dwdwdw,DC=com';
  </code></pre>
  
  <p>, it authenticates perfectly. </p>
  
  <p>I have used usertodnmapping while enabling LDAP on MongoDB successfully. </p>
  
  <pre><code>userToDNMapping: |-
    [
          {
           match: "(.+)",
           ldapQuery: "dc=ads,dc=dwdwdw,dc=com??sub?(samAccountName={0})"
          }
         ]
  </code></pre>
  
  <p>But I just cannot seem to find the equivalent of it to use in activedirectory package. Could you please help me with it?</p>
  
  <p>I would not mind using ldapjs as well. I just haven't had much success with that either. I just want to get authenticated in with the username, and get the username's group memberships.</p>