gheeres / node-activedirectory

ActiveDirectory is an Node.js ldapjs client for authN (authentication) and authZ (authorization) for Microsoft Active Directory with range retrieval support for large Active Directory installations.
MIT License
534 stars 146 forks source link

TypeError: Cannot convert undefined or null to object #246

Open lfcastilhos opened 1 year ago

lfcastilhos commented 1 year ago

Team, recompile my PCF code from 22/2/2023 and I got the error below. Nothing was changed in my code, except redeploy and package update. Also I see ldapjs was updated to version 3.0.0. Anyone having same issue?

/home/vcap/deps/0/node_modules/activedirectory/lib/activedirectory.js:416 delete result.controls; // Remove the controls array returned as part of the SearchEntry ^ TypeError: Cannot convert undefined or null to object at CorkedEmitter.onSearchEntry (/home/vcap/deps/0/node_modules/activedirectory/lib/activedirectory.js:416:5) at CorkedEmitter.emit (node:events:513:28) at CorkedEmitter.emit (/home/vcap/deps/0/node_modules/ldapjs/lib/corked_emitter.js:44:33) at sendResult (/home/vcap/deps/0/node_modules/ldapjs/lib/client/client.js:1233:22) at messageCallback (/home/vcap/deps/0/node_modules/ldapjs/lib/client/client.js:1253:14) at Parser.onMessage (/home/vcap/deps/0/node_modules/ldapjs/lib/client/client.js:919:14) at Parser.emit (node:events:513:28) at Parser.write (/home/vcap/deps/0/node_modules/ldapjs/lib/messages/parser.js:135:8) at TLSSocket.onData (/home/vcap/deps/0/node_modules/ldapjs/lib/client/client.js:875:22) at TLSSocket.emit (node:events:513:28) Node.js v18.12.11

lfcastilhos commented 1 year ago

No issues using ldapjs 2.3.3. looks like it's incompatible with ldapjs 3.0.0.;

andreeib commented 1 year ago

Indeed, adding an override in package.json fixes the issue for now:

  "overrides": {
    "activedirectory": {
      "ldapjs": "2.3.3"
    }
  }
OzukaruCid commented 1 year ago

Hi,, y added the override from adreeib, but still the `errror..!!

`{ "dependencies": { "activedirectory": "^0.7.2" }

,"overrides": {
  "activedirectory": {
     "ldapjs": "2.3.3"
   }

} }`

OzukaruCid commented 1 year ago

it's work now,, i'm sorry still learning..

willcallender commented 12 months ago

I'm having the same issue, except that mine is persistent even after applying the fixes suggested here and in #60. The code that generates the error is

ad.findUser(username, (err, user) => {
  console.log('something');
  if (err) {
    console.log('ERROR: ' + JSON.stringify(err));
    return;
  }

  if (user) {
    console.log('User: ' + JSON.stringify(user));
  } else {
    console.log('User: ' + username + ' not found.');
  }
});

And my updated package.json

...
  "dependencies": {
    "activedirectory": "^0.7.2",
    "cors": "^2.8.5",
    "express": "^4.18.2",
    "moment": "^2.29.4",
    "pg": "^8.11.3"
  },
  "overrides": {
    "activedirectory": {
      "ldapjs": "2.3.3"
    }
  }

I get the same exact error as previous comments. The node server is running in portainer and the container has been destroyed and recreated. I have also rebooted the physical server with no effect. Commenting out the affected line in activedirectory.js bypasses the fatal error, but is unable to find the user. Any suggestions? Thanks!

joaopenas commented 12 months ago

Hello @willcallender I have been getting the same issue in the last 2 weeks and I have not solution for this. I started change implementation to use ldapts library. If you want some help to change it I can help you ;)

OzukaruCid commented 12 months ago

Hola a todos:

La implementación de ldap en mi proyecto es muy básico... tuve el mismo problema y estuve a punto de desistir pero instale activedirectory2... Y con eso quedó resuelto...

Saludos

El vie., 27 oct 2023 3:55 a. m., João Penas @.***> escribió:

Hello @willcallender https://github.com/willcallender I have been getting the same issue in the last 2 weeks and I have not solution for this. I started change implementation to use ldapts library. If you want some help to change it I can help you ;)

— Reply to this email directly, view it on GitHub https://github.com/gheeres/node-activedirectory/issues/246#issuecomment-1782549566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFFZCE26AKS7G6VKZ4QVQTYBNZJPAVCNFSM6AAAAAAVGBEDRKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBSGU2DSNJWGY . You are receiving this because you commented.Message ID: @.***>

willcallender commented 12 months ago

@OzukaruCid that worked immediately! Thank you!