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.

ldapmodify works, but ldapjs client.modify() does't work as expected and return No Such Object #950

@eliellima00

Description

@eliellima00

I'm triyng to update, a user. When I use ldapmodify from ldap-utils it works as expected.
ldapmodify -x -H ldap://grupoatto.corp:389 -D user -W -f modificacoes.ldif

my file has that content

dn: CN=ALDAIR NATAN BEZERRA DO NASCIMENTO GOMES,OU=Usuários,OU=Tecnologia da Informação,OU=Matriz,OU=GrupoATTO,DC=grupoatto,DC=corp
changetype: modify
replace: telephoneNumber
telephoneNumber: 00000000

But, when I use the same dn with client.modify()
I see that error

No Such Object
    at messageCallback (/home/eliel/projetos/password-recovery/password-recovery-api/node_modules/ldapjs/lib/client/client.js:1267:45)
    at Parser.onMessage (/home/eliel/projetos/password-recovery/password-recovery-api/node_modules/ldapjs/lib/client/client.js:925:14)
    at Parser.emit (node:events:513:28)
    at Parser.write (/home/eliel/projetos/password-recovery/password-recovery-api/node_modules/ldapjs/lib/messages/parser.js:135:8)
    at Socket.onData (/home/eliel/projetos/password-recovery/password-recovery-api/node_modules/ldapjs/lib/client/client.js:875:22)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  lde_message: 'No Such Object',
  lde_dn: 'OU=Matriz,OU=GrupoATTO,DC=grupoatto,DC=corp'

I don't know if it's a bug or if I'm making something wrong.

here is my code

    const client = createClient({
      url: ldapUri,
    });

    client.bind(adminDN, adminPassword, (err) => {
      if (err) {
        console.error('Erro ao autenticar como administrador:', err);
        return;
      }

      console.log('Autenticado como administrador');

      const change = new Change({
        operation: 'replace',
        modification: {
          type: 'givenName',
          values: ['ALDAIR'],
        },
      });

      const userDN = 'CN=USER TO MODIFY ,OU=Usuários,OU=Tecnologia da Informação,OU=Matriz,OU=GrupoATTO,DC=grupoatto,DC=corp'

      client.modify(userDN, change, (err) => {
        if (err) {
          console.error('Erro ao atualizar o telefone do usuário:', err);
        } else {
          console.log('Telefone atualizado com sucesso.');
        }

        // Fechar a conexão LDAP
        client.unbind((err) => {
          if (err) {
            console.error('Erro ao fechar a conexão LDAP:', err);
          } else {
            console.log('Conexão LDAP encerrada.');
          }
        });
      });
    });
I know that don't have any problen with tree authorization, because with ldapmodify work's as expected

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