Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Active Directory Error in findUser function

I have the following code in my javascript:

var ad = new ActiveDirectory(adConfig);
        ad.authenticate(username, password, function (err, auth) {
            if (err) {
                console.error("ERROR : " + JSON.stringify(err));
                res.send(false);
                return;
            }
            if (auth) {
                console.log("User " + username.split('\\')[1] + " authenticated");
                ad.findUser(username.split('\\')[1], function (err, user) {
                    //More code here
                }

My program reaches to the ad.findUser line, but there, I get the following error:

activedirectory.js:416 delete result.controls; // Remove the controls array returned as part of the SearchEntry ^ TypeError: Cannot convert undefined or null to object

Line 416 of file activedirectory.js is the one that starts with 'delete' here:

function onSearchEntry(entry) {
    log.trace('onSearchEntry(%j)', entry);
    console.log('entry', entry);
    var result = entry.object;
    delete result.controls; // Remove the controls array returned as part of the SearchEntry
    ...

My 'entry' object is of type SearchResultEntry [LdapMessage] {...}, which effectivement does not have a 'object' attribute, so 'result' is undefined. That's why my code is not working. However, I do not understand why I arrive to that situation.

Any clue?

like image 301
IAyestaran Avatar asked Dec 16 '25 12:12

IAyestaran


1 Answers

According to this GitHub issue, it seems like the activedirectory library doesn't work with ldapjs 3.0.0, so you may need to add an override in your package.json:

"overrides": {
  "activedirectory": {
    "ldapjs": "2.3.3"
  }
}
like image 196
Gabriel Luci Avatar answered Dec 19 '25 06:12

Gabriel Luci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!