node-ldapauth icon indicating copy to clipboard operation
node-ldapauth copied to clipboard

LDAP auth not working

Open aswanthvp opened this issue 5 years ago • 0 comments

i have older passport and passport-ldap package with that authentication is working and when installed the latest package authentication is not happening its giving Unauthorized as output. this is my code:

` var express = require('express'), passport = require('passport'), bodyParser = require('body-parser'), LdapStrategy = require('passport-ldapauth');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; var OPTS = { server: { url: "ldaps://--------------" bindDn: 'ZGN', bindCredentials: 'password', searchBase: 'DC=---------,DC=-----', searchFilter: '(samaccountName={{username}})', searchAttributes: ["displayName", "givenName", "mail", "title", "telephoneNumber", "samaccountname", "userPrincipalName"], } // , // usernameField: 'username', // passwordField: 'password' };

var app = express();

passport.use(new LdapStrategy(OPTS));

app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: false})); app.use(passport.initialize());

app.post('/login', passport.authenticate('ldapauth', {session: false}), function(req, res) { res.send({status: 'ok'}); }); //API call with parameter // { // "username":"coreid", // "password":"password" // }

app.listen(8080); `

aswanthvp avatar Feb 13 '20 10:02 aswanthvp