Node-ldapjs: the client reconnection is not documented

Created on 14 Oct 2016  路  5Comments  路  Source: ldapjs/node-ldapjs

I was having some problems connecting to a balanced ldap and reading the code I found the solution undocumented.

var client = ldap.createClient({
        url: config.ldap.url,
        reconnect:true
});
has-pr

Most helpful comment

A little late, maybe. For others enter this issue later:

    // e.g. in your client's class constructor

    this.ldapClient = ldap.createClient({
        url: ldap_url,
        reconnect: {
            initialDelay: 100,
            maxDelay: 1000,
            failAfter: 10
        }
    });

    const client = this.ldapClient;
    // do a rebind when reconnect
    this.ldapClient.on('connect', function () {
        client.bind(ldap_user, ldap_pwd, err => {
            if (err) {
                logger.error('error while ldap binding' + err);
            }
        });
    });

All 5 comments

with this option can reconnect but not rebind. I 'm working to figure out how to do a rebind after client reconnect.

@ivanhuay Did you find a solution for your problem?

@strebl Not for the moment I check the results of the query and based on that I make a rebind or not

A little late, maybe. For others enter this issue later:

    // e.g. in your client's class constructor

    this.ldapClient = ldap.createClient({
        url: ldap_url,
        reconnect: {
            initialDelay: 100,
            maxDelay: 1000,
            failAfter: 10
        }
    });

    const client = this.ldapClient;
    // do a rebind when reconnect
    this.ldapClient.on('connect', function () {
        client.bind(ldap_user, ldap_pwd, err => {
            if (err) {
                logger.error('error while ldap binding' + err);
            }
        });
    });

A little late, maybe. For others enter this issue later:

    // e.g. in your client's class constructor

    this.ldapClient = ldap.createClient({
        url: ldap_url,
        reconnect: {
            initialDelay: 100,
            maxDelay: 1000,
            failAfter: 10
        }
    });

    const client = this.ldapClient;
    // do a rebind when reconnect
    this.ldapClient.on('connect', function () {
        client.bind(ldap_user, ldap_pwd, err => {
            if (err) {
                logger.error('error while ldap binding' + err);
            }
        });
    });

Will this cause bind to execute twice on the first connect?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djholly123 picture djholly123  路  3Comments

phi1ipp picture phi1ipp  路  4Comments

ifroz picture ifroz  路  8Comments

randomsock picture randomsock  路  7Comments

danez picture danez  路  8Comments