Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit d0a4f10

Browse files
committed
Initial commit
1 parent c17af9c commit d0a4f10

File tree

6 files changed

+355
-0
lines changed

6 files changed

+355
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ build/Release
2626
# Dependency directory
2727
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
2828
node_modules
29+
30+
# IDE
31+
.idea
32+
33+
# File system
34+
.DS_Store

package-lock.json

Lines changed: 267 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "node-red-contrib-better-ldap",
3+
"version": "0.0.0",
4+
"description": "A better node for LDAP communication.",
5+
"main": "transports/ldap/index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/rocky3598/node-red-contrib-better-ldap.git"
12+
},
13+
"keywords": [
14+
"better",
15+
"ldap",
16+
"redconnect"
17+
],
18+
"node-red": {
19+
"nodes": {
20+
"ldap": "transports/ldap/index.js"
21+
}
22+
},
23+
"author": "Jordan Vohwinkel <[email protected]>",
24+
"license": "MIT",
25+
"bugs": {
26+
"url": "https://github.com/rocky3598/node-red-contrib-better-ldap/issues"
27+
},
28+
"homepage": "https://github.com/rocky3598/node-red-contrib-better-ldap#readme",
29+
"dependencies": {
30+
"ldapjs": "^1.0.2"
31+
}
32+
}

transports/ldap/index.html

Whitespace-only changes.

transports/ldap/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = function (RED) {
2+
'use strict';
3+
4+
function ldapNode(n) {
5+
RED.nodes.createNode(this, n);
6+
}
7+
8+
RED.nodes.registerType('ldap', ldapNode, {
9+
credentials: {
10+
username: { type: "text" },
11+
password: { type: "password" }
12+
}
13+
});
14+
};

transports/ldap/ldap.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const ldap = require('ldapjs');
2+
module.exports = {
3+
client: undefined,
4+
connect: async function(url, username, password, options) {
5+
let that = this;
6+
this.client = ldap.createClient({
7+
url,
8+
...options
9+
});
10+
return new Promise(function (resolve, reject) {
11+
that.client.bind(username, password, function(err, conn) {
12+
if (err) return reject(err);
13+
return resolve(conn);
14+
});
15+
});
16+
},
17+
update: async function (dn, operation, attribute, value) {
18+
let that = this;
19+
let changeObj = {
20+
operation,
21+
modification: {}
22+
};
23+
changeObj.modification[attribute] = value;
24+
let change = new ldap.Change(changeObj);
25+
26+
return new Promise(function (resolve, reject) {
27+
that.client.modify(dn, change, function(err, res) {
28+
console.log('');
29+
if (err) {
30+
return reject({ success: false, error: err });
31+
}
32+
return resolve({ success: true });
33+
});
34+
});
35+
}
36+
}

0 commit comments

Comments
 (0)