ldapjs / node-ldapjs

LDAP Client and Server API for node.js
http://ldapjs.org
MIT License
1.61k stars 448 forks source link

How to decode my search result? #876

Closed classmatewu closed 1 year ago

classmatewu commented 1 year ago

Hi, the "node-ldapjs" is very excellent and amazing, but I met some trouble when I client.search basedn, the Chinese String encode to the “gibberish”, why? and how can I do to decode? Thanks a lot.

image

"\e7\a0\94\e5\8f\91\e4\ba\8c\e7\bb\84"-> "研发二组"

jsumners commented 1 year ago

It is not "gibberish". It is escaped as per the spec (https://www.rfc-editor.org/rfc/rfc4514). What is the use case for the unescaped string?

classmatewu commented 1 year ago

It is not "gibberish". It is escaped as per the spec (https://www.rfc-editor.org/rfc/rfc4514). What is the use case for the unescaped string?

"\e7\a0\94\e5\8f\91\e4\ba\8c\e7\bb\84"-> "研发二组"

jsumners commented 1 year ago

Please write actual explanations. Simply responding:

"\e7\a0\94\e5\8f\91\e4\ba\8c\e7\bb\84"-> "研发二组"

is not sufficient explanation of anything. It literally says nothing.

classmatewu commented 1 year ago

Please write actual explanations. Simply responding:

"\e7\a0\94\e5\8f\91\e4\ba\8c\e7\bb\84"-> "研发二组"

is not sufficient explanation of anything. It literally says nothing.

this is my demo

client.search(baseDN, {
    filter: 'objectclass=organizationalUnit',
    scope: 'one',
    attributes: ['o', 'ou']
  }, (err, res) => {
    if (err) {
      console.log(err);
    } else {
      res.on('searchEntry', (entry) => {
        console.log('dn: ' + entry.dn.toString());
        // "ou=\e7\a0\94\e5\8f\91\e4\ba\8c\e7\bb\84,o=test,dc=test,dc=com"
        // expect: "ou=研发二组,o=test,dc=test,dc=com"
      });

      res.on('error', function (err) {
        console.error('error: ' + err.message);
        client.unbind();
      });

      res.on('end', function (result) {
        console.log('search status: ' + result.status);
        client.unbind();
      });
    }
  });
jsumners commented 1 year ago

https://github.com/ldapjs/dn/releases/tag/v1.1.0 has been published. Please update your dependencies and then code.

classmatewu commented 1 year ago

https://github.com/ldapjs/dn/releases/tag/v1.1.0 has been published. Please update your dependencies and then code.

so good, thanks a lot.

classmatewu commented 1 year ago

Please also update the npm of node-ldapjs, thanks a lot.

roy2651 commented 1 year ago

Please also update the npm of node-ldapjs, thanks a lot.

请问一下如何解析这个entry.dn,新建的账号dn带有中文是如何解析,我直接写中文,报错no such object