I am having problems authenticating with the Active Directory server using the tools / applications mentioned in the header.
I am using the AD test environment found here. Here are the relevant code snippets if anyone has any suggestions that I really appreciate.
Currently, the error I am getting is "invalid username / password". I'm not sure if this is the bindDn / pw account or the one the user enters into the form. According to the project passport-ldapauth it is:
invalidCredentials flash message for InvalidCredentialsError NoSuchObjectError, and /no such user/i LDAP errors (default: 'Invalid username/password')
Thanks in advance.
CLIENT - auth.service.js
... login: function(user, callback) { var cb = callback || angular.noop; var deferred = $q.defer(); $http.post('/auth/ldap', { email: user.email, password: user.password }). success(function(data) { $cookieStore.put('token', data.token); currentUser = User.get(); deferred.resolve(data); return cb(); }). error(function(err) { this.logout(); deferred.reject(err); return cb(err); }.bind(this)); return deferred.promise; }, ...
SERVER index.js
'use strict'; var express = require('express'); var passport = require('passport'); var auth = require('../auth.service'); var router = express.Router(); router.post('/', function(req, res, next) { passport.authenticate('ldapauth', function (err, user, info) { var error = err || info; if (error) return res.json(401, error); if (!user) return res.json(404, {message: 'Something went wrong, please try again.'}); var token = auth.signToken(user._id, user.role); res.json({token: token}); })(req, res, next) }); module.exports = router;
SERVER passport.js
var passport = require('passport'); var LdapStrategy = require('passport-ldapauth').Strategy; exports.setup = function (User, config) { passport.use(new LdapStrategy({ usernameField: 'email', passwordField: 'password', server: { url: 'ldap://ldap.forumsys.com:389', bindDn: "cn=read-only-admin,dc=example,dc=com", bindCredentials: "password", searchBase: 'ou=mathematicians,dc=example,dc=com', searchFilter: 'uid={{username}}' } }, function (user, done) { return done(null, user); } )); };