LDAP Plugin
-
I have a directory inside
nodebb_mobules
callednodebb-plugin-node-ldap-new
and the below variables insideindex.js
var user = require.main.require('./src/user'), groups = require.main.require('./src/groups'), meta = require.main.require('./src/meta'), db = require.main.require('./src/database'), passport = require.main.require('passport'), async = require.main.require('async'), local_strategy = require.main.require('passport-local').Strategy, winston = require.main.require('winston'), ldapjs = require('ldapjs'); const controllers = require.main.require('./src/controllers');
-
-
@baris the extension works in terms of no errors on install or activation, but doesn't work in the sense of actually logging in
Below are the errors generated when attempting to login via LDAP or AD
2022-11-01T09:49:46.122Z [4567/400206] - error: uncaughtException: input string cannot be empty AssertionError [ERR_ASSERTION]: input string cannot be empty at Object.parse (/home/etp/domains/kb.etp.local/nodebb/node_modules/ldap-filter/lib/index.js:246:12) at Object.parseString (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/filters/index.js:179:27) at Client.search (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:569:30) at /home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:190:41 at /home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:152:17 at callbackWrapper (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:292:5) at sendResult (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:1195:12) at messageCallback (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:1218:16) at Parser.onMessage (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:884:14) at Parser.emit (node:events:513:28) {"date":"Tue Nov 01 2022 09:49:46 GMT+0000 (Coordinated Universal Time)","error":{"actual":false,"code":"ERR_ASSERTION","expected":true,"generatedMessage":false,"operator":"=="},"exception":true,"os":{"loadavg":[0.51,0.28,0.1],"uptime":423502.22},"process":{"argv":["/usr/bin/node","/home/etp/domains/kb.etp.local/nodebb/app.js"],"cwd":"/home/etp/domains/kb.etp.local/nodebb","execPath":"/usr/bin/node","gid":1001,"memoryUsage":{"arrayBuffers":19229585,"external":21369256,"heapTotal":87359488,"heapUsed":81645168,"rss":155594752},"pid":400206,"uid":1001,"version":"v16.18.0"},"stack":"AssertionError [ERR_ASSERTION]: input string cannot be empty\n at Object.parse (/home/etp/domains/kb.etp.local/nodebb/node_modules/ldap-filter/lib/index.js:246:12)\n at Object.parseString (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/filters/index.js:179:27)\n at Client.search (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:569:30)\n at /home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:190:41\n at /home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:152:17\n at callbackWrapper (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:292:5)\n at sendResult (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:1195:12)\n at messageCallback (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:1218:16)\n at Parser.onMessage (/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js:884:14)\n at Parser.emit (node:events:513:28)","trace":[{"column":12,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/ldap-filter/lib/index.js","function":"Object.parse","line":246,"method":"parse","native":false},{"column":27,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/filters/index.js","function":"Object.parseString","line":179,"method":"parseString","native":false},{"column":30,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js","function":"Client.search","line":569,"method":"search","native":false},{"column":41,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js","function":null,"line":190,"method":null,"native":false},{"column":17,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js","function":null,"line":152,"method":null,"native":false},{"column":5,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js","function":"callbackWrapper","line":292,"method":null,"native":false},{"column":12,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js","function":"sendResult","line":1195,"method":null,"native":false},{"column":16,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js","function":"messageCallback","line":1218,"method":null,"native":false},{"column":14,"file":"/home/etp/domains/kb.etp.local/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/node_modules/ldapjs/lib/client/client.js","function":"Parser.onMessage","line":884,"method":"onMessage","native":false},{"column":28,"file":"node:events","function":"Parser.emit","line":513,"method":"emit","native":false}]}
The below error is also shown when attempting to login
-
I am not familiar with how the ldap plugin works, but the error seems to complain about some missing config. What values did you put in the ACP page? For reference the stack trace you posted points to this line in the plugin, so maybe
master_config.base
is missing or empty. -
Hi, i tried your solution... i looks firstly "okay"... but when i try to login i got this:
screen:
error log:
2022-11-14T13:00:54.323Z [4567/83669] - error: uncaughtException: Cannot read properties of undefined (reading 'indexOf') TypeError: Cannot read properties of undefined (reading 'indexOf') at Object.login (/root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:257:23) at /root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:212:57 at callbackWrapper (/root/nodebb/node_modules/ldapjs/lib/client/client.js:292:5) at sendResult (/root/nodebb/node_modules/ldapjs/lib/client/client.js:1195:12) at messageCallback (/root/nodebb/node_modules/ldapjs/lib/client/client.js:1218:16) at Parser.onMessage (/root/nodebb/node_modules/ldapjs/lib/client/client.js:884:14) at Parser.emit (node:events:513:28) at Parser.write (/root/nodebb/node_modules/ldapjs/lib/messages/parser.js:107:8) at Socket.onData (/root/nodebb/node_modules/ldapjs/lib/client/client.js:871:22) at Socket.emit (node:events:513:28) {"date":"Mon Nov 14 2022 13:00:54 GMT+0000 (Koordinierte Weltzeit)","error":{},"exception":true,"os":{"loadavg":[0.34,0.13,0.04],"uptime":3028451.94},"process":{"argv":["/usr/bin/node","/root/nodebb/app.js"],"cwd":"/root/nodebb","execPath":"/usr/bin/node","gid":0,"memoryUsage":{"arrayBuffers":19463885,"external":21643628,"heapTotal":100155392,"heapUsed":92994872,"rss":172048384},"pid":83669,"uid":0,"version":"v18.12.1"},"stack":"TypeError: Cannot read properties of undefined (reading 'indexOf')\n at Object.login (/root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:257:23)\n at /root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js:212:57\n at callbackWrapper (/root/nodebb/node_modules/ldapjs/lib/client/client.js:292:5)\n at sendResult (/root/nodebb/node_modules/ldapjs/lib/client/client.js:1195:12)\n at messageCallback (/root/nodebb/node_modules/ldapjs/lib/client/client.js:1218:16)\n at Parser.onMessage (/root/nodebb/node_modules/ldapjs/lib/client/client.js:884:14)\n at Parser.emit (node:events:513:28)\n at Parser.write (/root/nodebb/node_modules/ldapjs/lib/messages/parser.js:107:8)\n at Socket.onData (/root/nodebb/node_modules/ldapjs/lib/client/client.js:871:22)\n at Socket.emit (node:events:513:28)","trace":[{"column":23,"file":"/root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js","function":"Object.login","line":257,"method":"login","native":false},{"column":57,"file":"/root/nodebb/node_modules/@nodebb/nodebb-plugin-node-ldap/index.js","function":null,"line":212,"method":null,"native":false},{"column":5,"file":"/root/nodebb/node_modules/ldapjs/lib/client/client.js","function":"callbackWrapper","line":292,"method":null,"native":false},{"column":12,"file":"/root/nodebb/node_modules/ldapjs/lib/client/client.js","function":"sendResult","line":1195,"method":null,"native":false},{"column":16,"file":"/root/nodebb/node_modules/ldapjs/lib/client/client.js","function":"messageCallback","line":1218,"method":null,"native":false},{"column":14,"file":"/root/nodebb/node_modules/ldapjs/lib/client/client.js","function":"Parser.onMessage","line":884,"method":"onMessage","native":false},{"column":28,"file":"node:events","function":"Parser.emit","line":513,"method":"emit","native":false},{"column":8,"file":"/root/nodebb/node_modules/ldapjs/lib/messages/parser.js","function":"Parser.write","line":107,"method":"write","native":false},{"column":22,"file":"/root/nodebb/node_modules/ldapjs/lib/client/client.js","function":"Socket.onData","line":871,"method":"onData","native":false},{"column":28,"file":"node:events","function":"Socket.emit","line":513,"method":"emit","native":false}]}
-
Can you try with 2.0.2, I fixed that undefined crash. I am not really familiar with how this plugin works so make sure you fill out the necessary info in the ACP page.
For example the plugin seems to look for the email inprofile.mail
but if there is anemail_field
set in the acp config then it will try to get the email from there.nodebb-plugin-node-ldap/index.js at master · NodeBB-Community/nodebb-plugin-node-ldap
Log in to NodeBB using credentials stored in an OpenLDAP server. - nodebb-plugin-node-ldap/index.js at master · NodeBB-Community/nodebb-plugin-node-ldap
GitHub (github.com)
-
I found this listed in the NPM registry
https://github.com/Chrischenny/nodebb-plugin-node-ldap-adCan't get it to work though - crashes NodeBB every time.
EDIT - working now - I had the one amended by @baris still installed, so removed and all good from the stability perspective. Doesn't seem to work with AD though - at least, not for me - investigating.