-
Notifications
You must be signed in to change notification settings - Fork 141
Description
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);
`