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

NoSuchObjectError returned when i perform a search in starttls mode #354

Closed
Oladapo opened this issue Mar 10, 2016 · 4 comments
Closed

NoSuchObjectError returned when i perform a search in starttls mode #354

Oladapo opened this issue Mar 10, 2016 · 4 comments

Comments

@Oladapo
Copy link

Oladapo commented Mar 10, 2016

Hello, I'm sort of stuck. Having successfully binded and performed search queries in simple bind mode i get an error when i perform the same queries after binding in starttls mode. Here's a snippet of the code

var ou = 'ou=foo,dc=example,dc=bar'
var opts = { scope : 'sub' }
var dosomething  = function(err, res) {
  assert.ifError(err) 
  console.log(res);
}
var executeSearch = function(base,searchoptions,fn) {
  //NOTE: cli binded and starttls called in bind callback
  cli.search(base,searchoptions,[],function(err,res) {
    var arr = [];
    if(err) return fn(err);


res.on('searchEntry', function(entry) {
  arr.push(entry.object);
});

res.on('error', function(err) {
   console.error('the following error occured: \n' + err);
   fn(err);
});

res.on('end', function(result) {
   fn(null,arr)
});


   });

}

executeSearch(abase,opts, dosomething)

here's the error stack:

NoSuchObjectError: No Such Object
    at messageCallback (/home/dani/Dev/projects/eaglepost/src/eaglepost-admin/node_modules/ldapjs/lib/client/client.js:1419:45)
    at Parser.onMessage (/home/dani/Dev/projects/eaglepost/src/eaglepost-admin/node_modules/ldapjs/lib/client/client.js:1089:14)
    at emitOne (events.js:77:13)
    at Parser.emit (events.js:169:7)
    at Parser.write (/home/dani/Dev/projects/eaglepost/src/eaglepost-admin/node_modules/ldapjs/lib/messages/parser.js:117:8)
    at TLSSocket.onData (/home/dani/Dev/projects/eaglepost/src/eaglepost-admin/node_modules/ldapjs/lib/client/client.js:927:32)
    at emitOne (events.js:77:13)
    at TLSSocket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at TLSSocket.Readable.push (_stream_readable.js:110:10)
@Destreyf
Copy link

Destreyf commented Nov 2, 2016

I am having this same issue, running the query without StartTLS works flawlessly, however once i use StartTLS it claims it can't find the exact same object.

@Destreyf
Copy link

Destreyf commented Nov 2, 2016

After playing with this, i was able to get it working using this.

var ldap = require('ldapjs');
var client = ldap.createClient({url: 'ldap://ldap.example.com'});

client.starttls({},[],function(start_err,start_res){
    client.bind('dc=example,dc=com','secret',function(err){
        client.search('ou=Users,dc=example,dc=com', {scope: 'sub'}, [], function(search_err,res){
            res.on('searchEntry', function(entry) {
                console.log('entry: ' + JSON.stringify(entry.object));
            });
            res.on('searchReference', function(referral) {
                console.log('referral: ' + referral.uris.join());
            });
            res.on('error', function(err) {
                console.error('error: ' + err.message);
            });
            res.on('end', function(result) {
                console.log('status: ' + result.status);
            });
        });
    });
});

So this appears to be an issue with calling starttls -after- binding, rather than before, i also had some trouble with nested callbacks that would make wrapper.js freak out, so i just inlined all my code for my project.

@jsumners
Copy link
Member

client.starttls would be something you perform immediately after creating the client and before performing any other operations. So at the least, this could use some better documentation. A PR would be welcome.

@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.
Projects
None yet
Development

No branches or pull requests

3 participants