Class: Strategy

Strategy

new Strategy(options, verifyopt)

Strategy constructor
The LDAP authentication strategy authenticates requests based on the credentials submitted through an HTML-based login form.
Applications may supply a `verify` callback which accepts `user` object and then calls the `done` callback supplying a `user`, which should be set to `false` if user is not allowed to authenticate. If an exception occured, `err` should be set.
Options can be also given as function that accepts a callback end calls it with error and options arguments. Notice that the callback is executed on every authenticate call.
Example:
var LdapStrategy = require('passport-ldapauth').Strategy;
passport.use(new LdapStrategy({
    server: {
      url: 'ldap://localhost:389',
      bindDN: 'cn=root',
      bindCredentials: 'secret',
      searchBase: 'ou=passport-ldapauth',
      searchFilter: '(uid={{username}})',
      reconnect: true
    }
  },
  function(user, done) {
    return cb(null, user);
  }
));
Parameters:
Name Type Attributes Description
options Object | optionsCallback Configuration options or options returning function
Properties
Name Type Attributes Default Description
server Object ldapauth-fork options
usernameField string <optional>
username Form field name for username
passwordField string <optional>
password Form field name for password
passReqToCallback boolean <optional>
false If true, request is passed to verify callback
credentialsLookup credentialsLookup <optional>
Credentials lookup function to use instead of default
handleErrorAsFailures boolean <optional>
false Set to true to handle errors as login failures
failureErrorCallback failureErrorCallback <optional>
Function receives the occurred error when errors handled as failures
verify verifyCallback | verifyReqCallback | undefined <optional>
User verify callback
Source:

Methods

authenticate(req, optionsopt) → {undefined}

Authenticate the request coming from a form or such.
Parameters:
Name Type Attributes Description
req Object The HTTP request
options Object <optional>
Authentication options (flash messages). All messages have default values.
Properties
Name Type Attributes Description
badRequestMessage string <optional>
Message for missing username/password
invalidCredentials string <optional>
Message for InvalidCredentialsError, NoSuchObjectError, and /no such user/ LDAP errors
userNotFound string <optional>
Message for user not found
constraintViolation string <optional>
Message when account is locked (or other constraint violation)
invalidLogonHours string <optional>
Message for Windows AD invalidLogonHours error
invalidWorkstation string <optional>
Message for Windows AD invalidWorkstation error
passwordExpired string <optional>
Message for Windows AD passwordExpired error
accountDisabled string <optional>
Message for Windows AD accountDisabled error
accountExpired string <optional>
Message for Windows AD accountExpired error
passwordMustChange string <optional>
Message for Windows AD passwordMustChange error
accountLockedOut string <optional>
Message for Windows AD accountLockedOut error
Source:
Returns:
Type
undefined