Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Why does the bind method call fail without throwing exception information? #977

Open
zk923852367 opened this issue Apr 23, 2024 · 1 comment

Comments

@zk923852367
Copy link

zk923852367 commented Apr 23, 2024

var ldap =  require("ldapjs");
var client = ldap.createClient({
  url: 'ldap://192.168.11.22:389'
});
var opts = {
  filter: `(sAMAccountName=${username})`, 
  scope: 'sub',        
  timeLimit: 500      
};
client.bind('testUsername', 'testPassword', function (err1, res1) {
    client.search('DC=test,DC=com', opts, function (err2, res2) {
        res2.on('searchEntry', function (entry) {
            var user = entry.object;
            client.bind(user.dn, password, function (err3, res3) {
                if(err3){
                    console.error('error: ' + err3.message);
                    resolve(null);
                }else{
                    var obj = {};
                    obj.groupName = user.description;
                    resolve(obj);
                }
                client.unbind();
            });
        });
        res2.on('error', function(err4) {
            console.error('error: ' + err4.message);
            client.unbind();
            resolve(null);
        });
    });
});
@WanpengQian
Copy link

how about this sample code?

client.bind("XXX\\" + username, currentPassword, err => {
    const searchOptions = {
      filter: '(sAMAccountName=' + username + ')',
      attributes: ['distinguishedName'],
      scope: 'sub'
    };
   client.search("DC=xxx,DC=xxx,DC=xxx", searchOptions, (err, res) => {
      res.on('searchEntry', entry => {
        let dn = entry.pojo.objectName;
...
     }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants