UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

46 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveBinaryAttributes = exports.BINARY_AD_ATTRIBUTES = void 0; exports.createLdapClient = createLdapClient; const ldapts_1 = require("ldapts"); exports.BINARY_AD_ATTRIBUTES = ['objectGUID', 'objectSid']; const resolveEntryBinaryAttributes = (entry) => { Object.entries(entry) .filter(([k]) => exports.BINARY_AD_ATTRIBUTES.includes(k)) .forEach(([k]) => { entry[k] = entry[k].toString('hex'); }); return entry; }; const resolveBinaryAttributes = (entries) => { entries.forEach((entry) => resolveEntryBinaryAttributes(entry)); }; exports.resolveBinaryAttributes = resolveBinaryAttributes; async function createLdapClient(context, credentials, nodeDebug, nodeType, nodeName) { const protocol = credentials.connectionSecurity === 'tls' ? 'ldaps' : 'ldap'; const url = `${protocol}://${credentials.hostname}:${credentials.port}`; const ldapOptions = { url }; const tlsOptions = {}; if (credentials.connectionSecurity !== 'none') { tlsOptions.rejectUnauthorized = credentials.allowUnauthorizedCerts === false; if (credentials.caCertificate) { tlsOptions.ca = [credentials.caCertificate]; } if (credentials.connectionSecurity !== 'startTls') { ldapOptions.tlsOptions = tlsOptions; } } if (credentials.timeout) { // Convert seconds to milliseconds ldapOptions.timeout = credentials.timeout * 1000; } if (nodeDebug) { context.logger.info(`[${nodeType} | ${nodeName}] - LDAP Options: ${JSON.stringify(ldapOptions, null, 2)}`); } const client = new ldapts_1.Client(ldapOptions); if (credentials.connectionSecurity === 'startTls') { await client.startTLS(tlsOptions); } return client; } //# sourceMappingURL=Helpers.js.map