Socket
Socket
Sign inDemoInstall

ldap-ts-client

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-ts-client - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

33

dist/app.js

@@ -34,4 +34,19 @@ "use strict";

// };
// const addResult = client.add({ entry, dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local" });
// const addResult = await client.add({
// entry,
// dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",
// });
// console.log(addResult);
// const modifyResult = await client.modify({
// dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",
// changes: [
// {
// operation: "add",
// modification: {
// mail: "mymail@mydomain.com",
// },
// },
// ],
// });
// console.log(`File: app.ts,`, `Line: 53 => `, modifyResult);
// const compared = await client.compare({

@@ -43,12 +58,12 @@ // dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",

// console.log(`File: app.ts,`, `Line: 22 => `, compared);
// const data = await client.queryAttributes({
// options: {
// attributes: ["*"],
// filter: "(&(objectClass=organizationalPerson)(cn=test*))",
// scope: "sub",
// },
// });
// console.log(`File: app.ts,`, `Line: 17 => `, data[0]);
const data = await client.queryAttributes({
options: {
attributes: ["*"],
filter: "(&(objectClass=organizationalPerson)(cn=test*))",
scope: "sub",
},
});
console.log(`File: app.ts,`, `Line: 17 => `, data[0]);
await client.unbind();
})();
//# sourceMappingURL=app.js.map

@@ -15,2 +15,19 @@ import ldap, { SearchOptions, Control, SearchEntryObject } from "ldapjs";

}
/** A Change object maps to the LDAP protocol of a modify change, and requires you to set the operation and modification. The operation is a string, and must be one of:
* - replace: Replaces the attribute referenced in modification. If the modification has no values, it is equivalent to a delete.
* - add: Adds the attribute value(s) referenced in modification. The attribute may or may not already exist.
* - delete: Deletes the attribute (and all values) referenced in modification.
modification is just a plain old JS object with the values you want. */
interface Change {
operation: "add" | "delete" | "replace";
modification: {
[key: string]: any;
};
}
interface ModifyFnInput {
dn: string;
changes: Change[];
controls?: any;
}
interface QueryFnInput {

@@ -94,3 +111,6 @@ options?: SearchOptions;

modifyDn({ dn, newDn, controls, }: ModifyDnFnInput): Promise<boolean>;
/** Performs an LDAP modify operation against the existing LDAP entity. This API requires you to pass in a Change object.
*/
modify({ dn, changes, controls, }: ModifyFnInput): Promise<boolean>;
}
export {};

@@ -214,4 +214,29 @@ "use strict";

}
/** Performs an LDAP modify operation against the existing LDAP entity. This API requires you to pass in a Change object.
*/
async modify({ dn, changes, controls, }) {
var _a;
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.trace("modify()");
await this.connect();
return new Promise((resolve, reject) => {
if (controls) {
this.client.modify(dn, changes, controls, function modifyCallBack(error) {
if (error) {
reject(error);
}
resolve(true);
});
}
else {
this.client.modify(dn, changes, function modifyCallBack(error) {
if (error) {
reject(error);
}
resolve(true);
});
}
});
}
}
exports.Client = Client;
//# sourceMappingURL=index.js.map
{
"name": "ldap-ts-client",
"version": "0.3.0",
"version": "0.4.0",
"description": "Type-safe LDAP client written in typescript",

@@ -5,0 +5,0 @@ "repository": {

@@ -36,5 +36,21 @@ import { config } from "dotenv";

// };
// const addResult = client.add({ entry, dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local" });
// const addResult = await client.add({
// entry,
// dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",
// });
// console.log(addResult);
// const modifyResult = await client.modify({
// dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",
// changes: [
// {
// operation: "add",
// modification: {
// mail: "mymail@mydomain.com",
// },
// },
// ],
// });
// console.log(`File: app.ts,`, `Line: 53 => `, modifyResult);
// const compared = await client.compare({

@@ -47,12 +63,12 @@ // dn: "CN=testUser2,OU=Users,OU=KII,DC=ki,DC=local",

// const data = await client.queryAttributes({
// options: {
// attributes: ["*"],
// filter: "(&(objectClass=organizationalPerson)(cn=test*))",
// scope: "sub",
// },
// });
// console.log(`File: app.ts,`, `Line: 17 => `, data[0]);
const data = await client.queryAttributes({
options: {
attributes: ["*"],
filter: "(&(objectClass=organizationalPerson)(cn=test*))",
scope: "sub",
},
});
console.log(`File: app.ts,`, `Line: 17 => `, data[0]);
await client.unbind();
})();

@@ -18,2 +18,19 @@ import ldap, { SearchOptions, Control, SearchEntryObject } from "ldapjs";

/** A Change object maps to the LDAP protocol of a modify change, and requires you to set the operation and modification. The operation is a string, and must be one of:
* - replace: Replaces the attribute referenced in modification. If the modification has no values, it is equivalent to a delete.
* - add: Adds the attribute value(s) referenced in modification. The attribute may or may not already exist.
* - delete: Deletes the attribute (and all values) referenced in modification.
modification is just a plain old JS object with the values you want. */
interface Change {
operation: "add" | "delete" | "replace";
modification: {
[key: string]: any;
};
}
interface ModifyFnInput {
dn: string;
changes: Change[];
controls?: any;
}
interface QueryFnInput {

@@ -24,3 +41,2 @@ options?: SearchOptions;

}
interface Entry {

@@ -304,2 +320,32 @@ [key: string]: string | string[];

}
/** Performs an LDAP modify operation against the existing LDAP entity. This API requires you to pass in a Change object.
*/
public async modify({
dn,
changes,
controls,
}: ModifyFnInput): Promise<boolean> {
this.logger?.trace("modify()");
await this.connect();
return new Promise((resolve, reject) => {
if (controls) {
this.client.modify(dn, changes, controls, function modifyCallBack(
error,
) {
if (error) {
reject(error);
}
resolve(true);
});
} else {
this.client.modify(dn, changes, function modifyCallBack(error) {
if (error) {
reject(error);
}
resolve(true);
});
}
});
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc