小编Fer*_*ani的帖子

nodejs passport ldapauth"无法读取'未定义的'属性"

我正在尝试使用passport-ldapauth和express对LDAP服务器进行身份验证.

使用ldap url(ldap:// myserver ...)的身份验证工作正常,但是使用ldaps我得到:

TypeError: Cannot read property 'on' of undefined
    at setupSocket (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:111:14)
    at Client._connect (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:742:3)
    at new Client (...\ldapauth-fork\node_modules\ldapjs\lib\client\client.js:247:22)
    at Object.createClient (...\ldapauth-fork\node_modules\ldapjs\lib\client\index.js:60:12)
    at new LdapAuth (...\ldapauth-fork\lib\ldapauth.js:129:28)
    at handleAuthentication (...\passport-ldapauth\lib\passport-ldapauth\strategy.js:140:10)
    at Strategy.authenticate (...\passport-ldapauth\lib\passport-ldapauth\strategy.js:175:33)
    at attempt (...\passport\lib\middleware\authenticate.js:341:16)
    at authenticate (...\passport\lib\middleware\authenticate.js:342:7)
    at Layer.handle [as handle_request] (...\express\lib\router\layer.js:82:5)

我的代码基本上是这样的:

  ...
  passport.use(new LdapStrategy({
  server: {
    url: 'ldaps://myserver:636',
    searchBase: '...',
    searchFilter: '(uid={{username}})',
    tlsOptions: {
        ca: [
            fs.readFileSync('myCAcert.pem')
    ]
   }
    },
    session: false,
    usernameField:'u',
    passwordField:'p'
  }, 
 function(user,  done) {
   console.log("Interna: \nOK");
    console.log("u:");
    console.log(user.cn);
   return done(null, …
Run Code Online (Sandbox Code Playgroud)

ssl ldap node.js passport.js

7
推荐指数
1
解决办法
1920
查看次数

标签 统计

ldap ×1

node.js ×1

passport.js ×1

ssl ×1