lib/MyLdapAuth.js
function MyLdapAuth(opts) {
  this.opts = opts;
  assert.ok(opts.url);
  assert.ok(opts.searchBase);
  assert.ok(opts.searchFilter);

  // optional option: tls_ca

  this.log = opts.log4js && opts.log4js.getLogger('ldapauth');

  var clientOpts = {url: opts.url};
  if (opts.log4js && opts.verbose) {
    clientOpts.log4js = opts.log4js;
  }
}
function MyLdapAuth(opts) {
  this.opts = opts;
  assert.ok(opts.url);
  assert.ok(opts.searchBase);
  assert.ok(opts.searchFilter);

  // optional option: tls_ca

  this.log = opts.log4js && opts.log4js.getLogger('ldapauth');

  var clientOpts = {url: opts.url};
  if (opts.log4js && opts.verbose) {
    clientOpts.log4js = opts.log4js;
  }
}
function MyLdapAuth ( opts ) { this . opts = opts ; assert . ok ( opts . url ) ; assert . ok ( opts . searchBase ) ; assert . ok ( opts . searchFilter ) ; // optional option: tls_ca this . log = opts . log4js && opts . log4js . getLogger ( 'ldapauth' ) ; var clientOpts = { url : opts . url } ; if ( opts . log4js && opts . verbose ) { clientOpts . log4js = opts . log4js ; } }
Create the MyLdapAuth class which is a former super class of LdapAuth
until I ended up having to reimplement too much of it

@param opts {Object} config options. Keys (required, unless stated
otherwise) are:
url {String} E.g. 'ldaps://ldap.example.com:663'
adminDn {String} E.g. 'uid=myapp,ou=users,o=example.com'
adminPassword {String} Password for adminDn
searchBase {String} The base DN from which to search for users by
username. E.g. 'ou=users,o=example.com'
searchFilter {String} LDAP search filter with which to find a user by
username, e.g. '(uid={{username}})'. Use the literal '{{username}}'
to have the given username be interpolated in for the LDAP search.
log4js {Module} Optional. The require'd log4js module to use for logging.
If given this will result in TRACE-level loggin for MyLdapAuth
verbose {Boolean} Optional, default false. if `log4js` is also given,
this will add TRACE-level logging for ldapjs (quite verbose).
Additional @params opts (see LdapAuth for base params)
groupSearchBase {string} Base search location for groups
E.g. 'ou=Groups,dc=example,dc=com'
groupAttribute {string} Attribute of group that members belong to
E.g. 'member'
groupAttributeIsDN {boolean} If the groupAttribute is a DN or simple username
searchScope {string} LDAP search scobe to use for group searching
E.g. 'sub'
groupSearch {string} LDAP search filter for administrative group.
NOTE: filter must return only 1 group to work correctly
E.g.: 'cn=admin,ou=Groups,dc=example,dc=com'
Create the MyLdapAuth class which is a former super class of LdapAuth until I ended up having to reimplement too much of it