snippets_js
Integration
New integration from credential
const ldapClient = await yepcode.integration.ldap('credential-slug')
New integration from plain authentication data
const ldapClient = require("ldapjs").createClient({
url: ["url"]
});
ldapClient.on("error", (err) => {
console.log("error", err)
});
ldapClient.on("connect", () => {
console.log("connected")
});
Add Entry
Add entry
const entry = {
// Attributes
};
ldapClient.add("dn", entry, (err) => {
if (err) {
throw err;
}
// Completed
});
Bind
Bind
ldapClient.bind("dn", "secret", (err) => {
if (err) {
throw err;
}
// Completed
});
Search
Search
const options = {
filter: "filter",
};
ldapClient.search("dn", options, (err, res) => {
res.on("searchEntry", (entry) => {
console.log("entry: " + JSON.stringify(entry.object));
});
res.on("error", (err) => {
console.error("error: " + err.message);
});
});