Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ldapjs authentication error when binding to LDAP server

I have issue on connecting to LDAP server using ldapjs lib. For some reason I cannot bind to ldap server using my credentials:

var ldap = require('ldapjs');

function authDN(dn, password, cb) {
    var client = ldap.createClient({url: 'ldaps://myserver:1234'});

    client.bind(dn, password, function (err) {
        client.unbind();
        cb(err === null, err);
    });
}


function output(res, err) {
    if (res) {
        console.log('success');
    } else {
        console.log('failure' + err.message);
    }
}

// should print "success"
authDN('CN=J33nn,OU=Members,DC=domains', 'password', output);
// should print "failure"
authDN('cn=user', 'badpasswd', output);

To be perfectly sure I've checked my dn in LDAP and tested binding to LDAP using python script and it worked.

Any ideas what's wrong?

like image 493
J33nn Avatar asked Apr 18 '26 07:04

J33nn


1 Answers

Maybe the username format is wrong or your DN is not correct, instead of

CN=J33nn,OU=Members,DC=domains

Try using:

[email protected]

Or you should use a LDAP exlorer tool to check your real/correct DN name by bind to your LDAP server.

like image 157
Xianlin Avatar answered Apr 20 '26 19:04

Xianlin