0
votes

This is how i set up my passport-ldapauth strategy:

let OPT = {
    server: {
        url: 'ldap://****:389',
        bindDN: "",
        bindCredentials: "",
        searchBase: 'ou=Users,dc=astron,dc=hu',
        searchFilter: "(uid={{username}})"
    },
    usernameField: 'username',
    passwordField: 'password',
};
passport.use(new LdapStrategy(OPT, function (user, done) {
    if (user != null) {
        return done(null, user);
    } else return done(new Error("i dont know"), null)
}))
app.use(passport.initialize())

This is where is use it:

 async authenticate(req, res): Promise < boolean > {
         return new Promise < boolean > ((resolve,
                     reject) => {
                     let authenticate: express.RequestHandler = <express.RequestHandler>passport.authenticate('ldapauth', (error, user, info) => {
                if (error) {
                    return reject(error);
                }
                if (!user) {
                    return resolve(false);
                }
                req.user = user;
                resolve(true);
            });
            authenticate(req, res,
                null);
        }
        )
    }

And i get this error:

Error: getaddrinfo ENOTFOUND **** ****:389

at errnoException (dns.js:28:10)

at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

My question would be why do i get the error? I am sure the url and the username/password is correct.

2

2 Answers

0
votes

There is only one meaning of this error, your node application is not able to connect to ldap server. May be you are giving correct ip/host but its not accessible from the machine where you are running node application.

You can try to connect to ldap with some tools from the same machine and see if it is able to connect to server.

0
votes

I have same error when developing. I used restify (let restify = require('restify')) to make https call, in console it shows ENOTFOUND error without specific context. Then I switch to use other approach

  1. https (require('https'))
  2. xhr (const XMLHttpRequest = require('xhr2'))

I use both to make ajax call to the same API. It works without error.