Thanks to visit codestin.com
Credit goes to github.com

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

"No Such Object" when using Client Modify #923

@audn

Description

@audn

I'm getting "No Such Object" error when I try to modify a group, even though the DN provided is correct.

I added Bunyan to inspect logs, and I could see from the response that object was empty.

const client = ldap.createClient({
   url: 'LDAPS:/xxx',
   tlsOptions: {
      rejectUnauthorized: true,
      cert: fs.readFileSync('xx.pem'),
      ca: fs.readFileSync('xxx.pem'),
   },
   reconnect: false,
   log: new Bunyan({
      name: 'ldapjs',
      component: 'client',
      stream: process.stderr,
      level: 'trace',
   }),
});

Response:

{
   "name": "ldapjs",
   "component": "client",
   "hostname": "x",
   "pid": 33960,
   "clazz": "Client",
   "ldap_id": "x",
   "level": 10,
   "msg": "sending request {\"messageId\":3,\"protocolOp\":102,\"type\":\"ModifyRequest\",\"object\":{},\"changes\":[{\"operation\":\"add\",\"modification\":{\"type\":\"member\",\"values\":[\"CN=xx\"]}}],\"controls\":[]}",
   "time": "2023-08-02T11:58:39.461Z",
   "v": 0
}

Function for modifying:

client.modify('cn=foo,dc=example,dc=com', change, (err) => {
   if (err) {
      console.log(err);
      reject(new Error(err.message));
   } else {
      console.log('la til i gruppe %j', null);
      resolve(null);
   }
});

I solved it by manually editing the ensureDN function in the \node_modules\ldapjs\lib\client\client.js file from:

function ensureDN(input) {
  if (DN.isDn(input)) {
    return DN
  } else if (typeof (input) === 'string') {
    return DN.fromString(input)
  } else {
    throw new Error('invalid DN')
  }
}

To:

function ensureDN(input) {
  if (DN.isDn(input)) {
    return DN
  } else if (typeof (input) === 'string') {
    return input // instead of DN.fromString()
  } else {
    throw new Error('invalid DN')
  }
}

Is this a known issue, or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions