create openldap setup utilities,
prototype ldap api interface
This commit is contained in:
31
src/ldap.js
Normal file
31
src/ldap.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import ldap from "ldapjs";
|
||||
import { exit } from "process";
|
||||
|
||||
export class LDAP {
|
||||
#client = null;
|
||||
#paasBind = null;
|
||||
#baseDN = null;
|
||||
|
||||
constructor (url, paasBind, baseDN) {
|
||||
const opts = {
|
||||
url
|
||||
};
|
||||
this.#client = ldap.createClient(opts);
|
||||
this.#client.on("connectError", (err) => {
|
||||
console.err(`Error: could not establish connection to ${url}`);
|
||||
console.err(err);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
this.#paasBind = paasBind;
|
||||
this.#baseDN = baseDN;
|
||||
}
|
||||
|
||||
addUser (uid, entry) {}
|
||||
|
||||
getUser (uid) {}
|
||||
|
||||
modUser (uid, entry) {}
|
||||
|
||||
delUser (uid) {}
|
||||
}
|
30
src/main.js
Normal file
30
src/main.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import express from "express";
|
||||
import bodyParser from "body-parser";
|
||||
import cookieParser from "cookie-parser";
|
||||
import morgan from "morgan";
|
||||
import LDAP from "ldap.js";
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(cookieParser());
|
||||
app.use(morgan("combined"));
|
||||
|
||||
app.listen(global.db.listenPort, () => {
|
||||
console.log(`proxmoxaas-api v${global.api.version} listening on port ${global.db.listenPort}`);
|
||||
});
|
||||
|
||||
app.get("/:user", (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.post("/:user", (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.delete("/:user", (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.post("/:user/password", (req, res) => {
|
||||
|
||||
});
|
Reference in New Issue
Block a user