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

"No Such Object" when using Client Modify #923

Closed
audn opened this issue Aug 2, 2023 · 12 comments
Closed

"No Such Object" when using Client Modify #923

audn opened this issue Aug 2, 2023 · 12 comments

Comments

@audn
Copy link

audn commented Aug 2, 2023

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?

@jsumners
Copy link
Member

jsumners commented Aug 2, 2023

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

https://github.com/ldapjs/node-ldapjs/releases/tag/v3.0.4

@audn
Copy link
Author

audn commented Aug 2, 2023

Sorry I forgot to mention. I am on 3.0.4

@audn
Copy link
Author

audn commented Aug 2, 2023

The only way I've been able to fix this is by returning input instead of DN.fromString(input).

The DN.isDn() function seems to return false, even for the example DN used in the docs: cn=foo,dc=example,dc=com

@jsumners
Copy link
Member

jsumners commented Aug 3, 2023

I have created an integration test based upon this issue #926

I am not seeing the issue described.

jsumners added a commit that referenced this issue Aug 4, 2023
@jsumners
Copy link
Member

jsumners commented Aug 4, 2023

Closing as cannot reproduce. If you are able to provide a reproduction, or show how the integration test I added is insufficient, please reopen with that information.

@jsumners jsumners closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
@audn
Copy link
Author

audn commented Aug 7, 2023

https://github.com/audn/ldapjs-reproduction
Let me know if it works on your end @jsumners

@jsumners
Copy link
Member

jsumners commented Aug 7, 2023

Have you reviewed the integration test I added? Can you point out how it does not cover the issue?

Regarding your repo:

  1. https://github.com/audn/ldapjs-reproduction/blob/06453eb1342cf8fd371c3a3a700e648fd4ae29b5/package.json#L6 is not v3.0.4. The v3.0.4 release directly addresses the code block you are asserting is the issue.
  2. It is not a minimal reproduction. Please review https://stackoverflow.com/help/minimal-reproducible-example. Note: the integration test I provided is a good example of what a minimal reproduction looks like for this project.

@audn
Copy link
Author

audn commented Aug 8, 2023

I tried moving the user, and that fixed it. Do you have any limitations as of how deep we can drill?

Doesn't work: CN=user1,OU=Portal,OU=Users,OU=Tier,OU=Norge,DC=example,DC=com
Works: CN=user1,DC=example,DC=com

@jsumners
Copy link
Member

jsumners commented Aug 8, 2023

You have removed your code, so I cannot see what you are doing. I'm going to guess that you are searching for the entry to modify, setting a base DN at dc=example,dc=com, and not specifying scope=subtree.

This library does not impose any limits on DNs that are not present in the RFCs.

@audn
Copy link
Author

audn commented Aug 9, 2023

Can you add scope on modify?

https://github.com/audn/ldapjs-reproduction

@audn
Copy link
Author

audn commented Aug 10, 2023

It seems like it's returning "No Such Object" when using "ø" in the DN @jsumners

@jsumners
Copy link
Member

Please see #860.

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