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

Error [InvalidAsn1Error]: Expected 0x2: got 0x3 #714

Closed
ajay340 opened this issue Mar 31, 2021 · 8 comments
Closed

Error [InvalidAsn1Error]: Expected 0x2: got 0x3 #714

ajay340 opened this issue Mar 31, 2021 · 8 comments

Comments

@ajay340
Copy link

ajay340 commented Mar 31, 2021

I am trying to create a client to connect my company's ldap. However, I receive an error
jse_shortmsg: 'Parser error for 1__ldap://company:port', jse_cause: Error [InvalidAsn1Error]: Expected 0x2: got 0x3
My code:

const ldap = require("ldapjs");
const client = ldap.createClient({
    url : 'ldap://company:port',
});

client.on("error", (err) => {
    console.log("Client experienced an error: ", err);
});

async function searchUserbyUID(uid) {
    try{
        var opts ={
            filter: `(uid=${uid})`,
            scope: 'sub',
            attributes: ['dn', 'sn', 'cn']
        }
        client.search("o=company", opts, (res) => {
            return res;
        });
    } catch (Exception) {
        console.log(Exception)
    }
}

The full traceback:

VError: Parser error for 1__ldap://company:port: Expected 0x2: got 0x3
    at Parser.onParseError (/dir/node_modules/ldapjs/lib/client/client.js:888:26)
    at Parser.emit (node:events:378:20)
    at Parser.write (/dir/node_modules/ldapjs/lib/messages/parser.js:103:10)
    at Socket.onData (/dir/node_modules/ldapjs/lib/client/client.js:871:22)
    at Socket.emit (node:events:378:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  jse_shortmsg: 'Parser error for 1__ldap://company:port',
  jse_cause: Error [InvalidAsn1Error]: Expected 0x2: got 0x3
      at newInvalidAsn1Error (/dir/node_modules/asn1/lib/ber/errors.js:7:13)
      at Reader._readTag (/dir/node_modules/asn1/lib/ber/reader.js:230:11)
      at Reader.readInt (/dir/node_modules/asn1/lib/ber/reader.js:146:15)
      at Parser.getMessage (/dir/node_modules/ldapjs/lib/messages/parser.js:116:25)
      at Parser.write (/dir/node_modules/ldapjs/lib/messages/parser.js:96:20)
      at Socket.onData (/dir/node_modules/ldapjs/lib/client/client.js:871:22)
      at Socket.emit (node:events:378:20)
      at addChunk (node:internal/streams/readable:313:12)
      at readableAddChunk (node:internal/streams/readable:288:9)
      at Socket.Readable.push (node:internal/streams/readable:227:10),
  jse_info: {}
}
@UziTech
Copy link
Member

UziTech commented Apr 1, 2021

I'm not 100% sure but I think the error is saying that it expected an int and received a bit string. This might be an issue with the server.

@jsumners
Copy link
Member

jsumners commented Apr 1, 2021

I think you're showing that the error is happening during the searchUserbyUID invocation. So I agree with @UziTech. This looks like your server returning an unexpected ASN.1 message. Which means ldapjs is operating as it should by providing you with the error.

@ajay340
Copy link
Author

ajay340 commented Apr 1, 2021

Commenting out this function and just creating the client connection, I receive this same traceback on error.

@jsumners
Copy link
Member

jsumners commented Apr 1, 2021

Unfortunately, without a way to reproduce it all we can do is guess at things.

Have you enabled trace logging? https://github.com/ldapjs/node-ldapjs/blob/1570e049526fffc47df00615ce48860cf3da77b3/docs/client.md#note-on-logger

Have you tried stepping through it with the debugger and inspecting the messages/processing?

@ajay340
Copy link
Author

ajay340 commented Apr 1, 2021

Unfortunately, without a way to reproduce it all we can do is guess at things.

Have you enabled trace logging? https://github.com/ldapjs/node-ldapjs/blob/1570e049526fffc47df00615ce48860cf3da77b3/docs/client.md#note-on-logger

Have you tried stepping through it with the debugger and inspecting the messages/processing?

What type of information should I be looking for when I inspect through my debugger?

@jsumners
Copy link
Member

jsumners commented Apr 1, 2021

🤷‍♂️

@ghost
Copy link

ghost commented Jan 25, 2023

@ajay340 did you solve this problem?

@jsumners
Copy link
Member

👋

On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request.

Please see issue #839 for more information, including how to proceed if you feel this closure is in error.

@ldapjs ldapjs locked as resolved and limited conversation to collaborators Feb 22, 2023
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

3 participants