LDAP Plugin
-
@baris did you get a chance to look into this ?
I made the following changes
\node_modules\nodebb-plugin-node-ldap\index.js
const user = require.main.require('./src/user'); const meta = require.main.require('./src/meta'); const db = require.main.require('./src/database'); const winston = require.main.require('winston'); const passport = require.main.require('passport'); const fs = require.main.require('fs'); const path = require.main.require('path'); const nconf = require.main.require('nconf'); const async = require.main.require('async'); const local_strategy = require.main.require('passport-local').Strategy, ldapjs = require.main.require('ldapjs');
And in
plugin.json
{ "id": "nodebb-plugin-node-ldap", "name": "Node LDAP", "description": "An LDAP plugin", "url": "https://github.com/ink-blot/nodebb-plugin-node-ldap", "library": "./index.js", "hooks": [ { "hook": "static:app.load", "method": "init" }, { "hook": "action:auth.overrideLogin", "method": "override" }, { "hook": "filter:config.get", "method": "get_config" }, { "hook": "filter:admin.header.build", "method": "admin" } ], "modules": { "acpScripts": "/lib/node_ldap.js" }, "templates": "templates" }
Still get the same errors though
Many thanks
-
@baris Same error sadly
VM2161:2 Uncaught ReferenceError: require is not defined at <anonymous>:2:5 at W (admin.min.js?v=mnm8h9os1sc:48:826) at Pt (admin.min.js?v=mnm8h9os1sc:48:49754) at r.fn.init.append (admin.min.js?v=mnm8h9os1sc:48:50965) at r.fn.init.<anonymous> (admin.min.js?v=mnm8h9os1sc:48:52055) at Te (admin.min.js?v=mnm8h9os1sc:48:33415) at r.fn.init.html (admin.min.js?v=mnm8h9os1sc:48:51735) at admin.min.js?v=mnm8h9os1sc:1:24108 (anonymous) @ VM2161:2 W @ admin.min.js?v=mnm8h9os1sc:48 Pt @ admin.min.js?v=mnm8h9os1sc:48 append @ admin.min.js?v=mnm8h9os1sc:48 (anonymous) @ admin.min.js?v=mnm8h9os1sc:48 Te @ admin.min.js?v=mnm8h9os1sc:48 html @ admin.min.js?v=mnm8h9os1sc:48 (anonymous) @ admin.min.js?v=mnm8h9os1sc:1 Promise.then (async) (anonymous) @ admin.min.js?v=mnm8h9os1sc:1 (anonymous) @ admin.min.js?v=mnm8h9os1sc:1 Promise.then (async) g @ admin.min.js?v=mnm8h9os1sc:1 (anonymous) @ admin.min.js?v=mnm8h9os1sc:1 success @ admin.min.js?v=mnm8h9os1sc:1 D @ admin.min.js?v=mnm8h9os1sc:48 fireWith @ admin.min.js?v=mnm8h9os1sc:48 tt @ admin.min.js?v=mnm8h9os1sc:51 (anonymous) @ admin.min.js?v=mnm8h9os1sc:51 load (async) send @ admin.min.js?v=mnm8h9os1sc:51 ajax @ admin.min.js?v=mnm8h9os1sc:51 ajaxify.loadData @ admin.min.js?v=mnm8h9os1sc:1 ajaxify.go @ admin.min.js?v=mnm8h9os1sc:1 E @ admin.min.js?v=mnm8h9os1sc:1 (anonymous) @ admin.min.js?v=mnm8h9os1sc:1 dispatch @ admin.min.js?v=mnm8h9os1sc:48 me.handle @ admin.min.js?v=mnm8h9os1sc:48 admin.min.js?v=mnm8h9os1sc:1 error loading node_ldap Error: Cannot find module './node_ldap' at https://kb.etp.local/assets/admin.min.js?v=mnm8h9os1sc:2:25033 at async g (https://kb.etp.local/assets/admin.min.js?v=mnm8h9os1sc:1:33052) at async Promise.all (index 0) at async app.require (https://kb.etp.local/assets/admin.min.js?v=mnm8h9os1sc:2:54) at async https://kb.etp.local/assets/admin.min.js?v=mnm8h9os1sc:1:27039
-
https://github.com/csturiale/nodebb-plugin-node-ldap/blob/master/templates/nodebb_ldap.tpl#L134-L142 this block also needs to be removed from the template. It's already in this file https://github.com/csturiale/nodebb-plugin-node-ldap/blob/master/lib/nodebb_ldap.js
-
I forked it here https://github.com/NodeBB-Community/nodebb-plugin-node-ldap, the commit with the fixes https://github.com/NodeBB-Community/nodebb-plugin-node-ldap/commit/764d8c316b19a349371044be76a8ba5a396d2597.
Let me know if it works then I can publish it to npm as
@nodebb/nodebb-plugin-node-ldap
-
@baris getting a slew of errors as below
2022-10-31T15:43:29.836Z [4567/355627] - warn: [plugins/nodebb-plugin-node-ldap] The plugin.json field "library" is deprecated. Please use the package.json field "main" instead. 2022-10-31T15:43:29.837Z [4567/355627] - warn: [plugins] Unable to load library for: nodebb-plugin-node-ldap 2022-10-31T15:43:29.837Z [4567/355627] - error: Error: Cannot find module './user' Require stack: - /home/etp/domains/kb.etp.local/nodebb/src/plugins/index.js - /home/etp/domains/kb.etp.local/nodebb/src/meta/configs.js - /home/etp/domains/kb.etp.local/nodebb/src/meta/index.js - /home/etp/domains/kb.etp.local/nodebb/src/start.js - /home/etp/domains/kb.etp.local/nodebb/require-main.js - /home/etp/domains/kb.etp.local/nodebb/app.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Module.require (node:internal/modules/cjs/loader:1057:19) at /home/etp/domains/kb.etp.local/nodebb/node_modules/nodebb-plugin-node-ldap/index.js:4:40 at Object.<anonymous> (/home/etp/domains/kb.etp.local/nodebb/node_modules/nodebb-plugin-node-ldap/index.js:345:2) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Module.require (node:internal/modules/cjs/loader:1057:19) 2022-10-31T15:43:29.847Z [4567/355627] - warn: [plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it. * nodebb-rewards-essentials * nodebb-plugin-node-ldap
-
Did you check index.js for the proper require statements? They should look like
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'),
No
module.parent.require('./user')
, seems like you are still using an old version. -
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