1
ldapsearch -h myserver.123.com -b 'dc=123,dc=com' -x uid=myid

This command works for me. Gets what I want. But I try hard to implement this functionality to node.js

I try this example: I think that myserver.123.com doesn't need authentication. I don't know also how myserver.123.com is configured. What is important, the command above somehow works.

var password = '';
var username = 'myid';

var ldap = require('ldapjs');
var tlsOptions = {
    host: 'myid',
    port: '389'
};
var client = ldap.createClient({
    url: 'myserver.123.com',
    tlsOptions: tlsOptions
});

client.bind(username, password, function (err) {
    if (err) {
        console.log('Error occurred while binding');
    } else {
        var base = 'cn=user,dc=123,dc=com';
        var search_options = {
            scope: 'sub',
            filter: '(&(objectClass=*)(CN=' + username + '))',
            attrs: 'memberOf'
        };
        client.search(base, search_options, function (err, res) {
            if (err) {
                console.log('Error occurred while ldap search');
            } else {
                res.on('searchEntry', function (entry) {
                    console.log('Entry', JSON.stringify(entry.object));
                });
                res.on('searchReference', function (referral) {
                    console.log('Referral', referral);
                });
                res.on('error', function (err) {
                    console.log('Error is', err);
                });
                res.on('end', function (result) {
                    console.log('Result is', result);
                });
            }
        });
    }
});

I am new in this technology. And I really don't know how make it works.

and this is my problem: "Error occurred while binding" I dont know how to bind to this server. I dont have any documentation. So yeah here is problem. I have my command above and now I improvises.

5
  • Without an error there's nothing we can do to help you figure this out. Please add more information. Commented May 15, 2017 at 9:01
  • getaddrinfo ENOTFOUND means that it can't find myserver.123.com. Make sure it's online and that you're using a real LDAP server. Commented May 15, 2017 at 9:19
  • What happens when you issue ping myserver.123.com from your CLI? Commented May 15, 2017 at 9:20
  • yeah, you are right, I pasted my previous error. Sorry for that. Error occurred while binding - this is my currend problem. Becouse I dont know how to bind server which doesnt need authentication Commented May 15, 2017 at 9:27
  • When I had dalated binding section I got an error: Error is { NoSuchObjectError: NoSuchObjectError at messageCallback...... Error: read ECONNRESET Commented May 15, 2017 at 9:51

1 Answer 1

-1

here is a solution:

[ldapjs authentification (user login setup)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.