vesse / passport-ldapauth

LDAP authentication strategy for Passport
MIT License
312 stars 100 forks source link

Unable to attempt authenticate #95

Closed SudoerWithAnOpinion closed 4 years ago

SudoerWithAnOpinion commented 4 years ago

If you know how to fix the issue, make a pull request instead.

Note: if the issue template is not used, the issue will be closed.

Problem Description

When attempting to authenticate during passport.authenticate(), this error is logged:

LdapErr: DSID-0C0907C2, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580

If I use LDAPAuth-fork directly, the admin account binds and successfully returns a user object. the options used for both LDAPAuth-fork and node

Steps to Reproduce

# from app.ts
import * as ldapAuthStrategy from 'passport-ldapauth'
const OPTS: ldapAuthStrategy.Options = {
  server: {
    url: process.env.AUTH_LDAP_URL,
    bindDN: process.env.AUTH_LDAP_BIND_USER_DN,
    bindCredentials: process.env.AUTH__LDAP_BIND_PASS,
    searchBase: "DC=example,DC=com,DC=us",
    searchFilter: "(sAMAccountName={{username}})"
  }
}
passport.use(new ldapAuthStrategy(OPTS, function(user:any, done:any){
  console.log("Passport LDAP Auth");
  done(null, user)
}));
# From a route .ts file (I have tried adding this portion to the relevant route file as well)
Router.post('/AUTH-LDAP/go', passport.authenticate('ldapauth'),
  (req: express.Request, res: express.Response)=>{
    res.send({status: 'ok'});
  }
)

The response received is

OperationsError: 000004DC: LdapErr: DSID-0C0907C2, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580
    at messageCallback (/Users/sinman/repositories/GoodTix/node_modules/ldapjs/lib/client/client.js:1419:45)
    at Parser.onMessage (/Users/sinman/repositories/GoodTix/node_modules/ldapjs/lib/client/client.js:1089:14)
    at Parser.emit (events.js:321:20)
    at Parser.write (/Users/sinman/repositories/GoodTix/node_modules/ldapjs/lib/messages/parser.js:111:8)
    at Socket.onData (/Users/sinman/repositories/GoodTix/node_modules/ldapjs/lib/client/client.js:1076:22)
    at Socket.emit (events.js:321:20)
    at addChunk (_stream_readable.js:305:12)
    at readableAddChunk (_stream_readable.js:280:11)
    at Socket.Readable.push (_stream_readable.js:214:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
SudoerWithAnOpinion commented 4 years ago

I neglected to mention this is attempting to bind against an Active Directory server.

SudoerWithAnOpinion commented 4 years ago

Turns out I mistyped an ENVVAR.