LDAP Plugin
-
@athedoor I managed to get this "working" in the sense that the settings apppear in the ACP, but the settings will not save
If you navigate to
<nodebbroot>\node_modules\nodebb-plugin-node-ldap
index.js` you'll see the below linesvar user = module.parent.require('user'), meta = module.parent.require('meta'), db = module.parent.require('database'),
Change those to
var user = module.parent.require('../user'), meta = module.parent.require('../meta'), db = module.parent.require('../database'),
Now rebuild and restart NodeBB and you should see the plugin in ACP and be able to get to the settings. What I haven't figued out yet is why the remainder does not work (doesn't save settings etc) - I see the below in the console
Uncaught ReferenceError: require is not defined at node_ldap:512:5
and
admin.min.js?v=5rmoufd2ukm:1 error loading node_ldap Error: Cannot find module './node_ldap' at https://kb.domain.local/assets/admin.min.js?v=5rmoufd2ukm:2:35260 at async g (https://kb.domain.local/assets/admin.min.js?v=5rmoufd2ukm:1:33416) at async Promise.all (index 0) at async app.require (https://kb.domain.local/assets/admin.min.js?v=5rmoufd2ukm:2:54) at async https://kb.domain.local/assets/admin.min.js?v=5rmoufd2ukm:1:27403
Just in the process of working through these.
-
-
@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');