Comparing version 1.0.6 to 1.1.0
@@ -0,1 +1,5 @@ | ||
### 1.1.0 | ||
* Add client.add() and client.modify() | ||
### 1.0.6 | ||
@@ -2,0 +6,0 @@ |
@@ -5,2 +5,4 @@ /// <reference types="node" /> | ||
import { Filter } from './filters/Filter'; | ||
import { Attribute } from './Attribute'; | ||
import { Change } from './Change'; | ||
export interface ClientOptions { | ||
@@ -68,2 +70,11 @@ /** | ||
/** | ||
* Used to create a new entry in the directory | ||
* @param {string} dn - DN of the entry to add | ||
* @param {Attribute[]|Object} attributes - Array of attributes or object where keys are the name of each attribute | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
add(dn: string, attributes: Attribute[] | { | ||
[index: string]: string | string[]; | ||
}, controls?: Control | Control[]): Promise<void>; | ||
/** | ||
* Compares an attribute/value pair with an entry on the LDAP server. | ||
@@ -74,3 +85,2 @@ * @param {string} dn - The DN of the entry to compare attributes with | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -82,3 +92,2 @@ compare(dn: string, attribute: string, value: string, controls?: Control | Control[]): Promise<boolean>; | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -91,3 +100,2 @@ del(dn: string, controls?: Control | Control[]): Promise<void>; | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -99,13 +107,13 @@ exop(oid: string, value?: string, controls?: Control | Control[]): Promise<{ | ||
/** | ||
* Performs an LDAP modify against the server. | ||
* @param {string} dn - The DN of the entry to modify | ||
* @param {Change|Change[]} changes | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
modify(dn: string, changes: Change | Change[], controls?: Control | Control[]): Promise<void>; | ||
/** | ||
* Performs an LDAP modifyDN against the server. | ||
* | ||
* This does not allow you to keep the old DN, as while the LDAP protocol | ||
* has a facility for that, it's stupid. Just Search/Add. | ||
* | ||
* This will automatically deal with "new superior" logic. | ||
* | ||
* @param {string} dn - The DN of the entry to modify | ||
* @param {string} newDN - The new DN to move this entry to | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -112,0 +120,0 @@ modifyDN(dn: string, newDN: string, controls?: Control | Control[]): Promise<void>; |
@@ -32,2 +32,5 @@ "use strict"; | ||
const StatusCodeParser_1 = require("./StatusCodeParser"); | ||
const Attribute_1 = require("./Attribute"); | ||
const AddRequest_1 = require("./messages/AddRequest"); | ||
const ModifyRequest_1 = require("./messages/ModifyRequest"); | ||
const MAX_MESSAGE_ID = Math.pow(2, 31) - 1; | ||
@@ -102,2 +105,47 @@ const logDebug = debug_1.default('ldapts'); | ||
/** | ||
* Used to create a new entry in the directory | ||
* @param {string} dn - DN of the entry to add | ||
* @param {Attribute[]|Object} attributes - Array of attributes or object where keys are the name of each attribute | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
async add(dn, attributes, controls) { | ||
if (!this.connected) { | ||
await this._connect(); | ||
} | ||
if (controls && !Array.isArray(controls)) { | ||
// tslint:disable-next-line:no-parameter-reassignment | ||
controls = [controls]; | ||
} | ||
let attributesToAdd; | ||
if (Array.isArray(attributes)) { | ||
attributesToAdd = attributes; | ||
} | ||
else { | ||
attributesToAdd = []; | ||
for (const [key, value] of Object.entries(attributes)) { | ||
let values; | ||
if (Array.isArray(value)) { | ||
values = value; | ||
} | ||
else { | ||
values = [value]; | ||
} | ||
attributesToAdd.push(new Attribute_1.Attribute({ | ||
type: key, | ||
values, | ||
})); | ||
} | ||
} | ||
const req = new AddRequest_1.AddRequest({ | ||
messageId: this._nextMessageId(), | ||
dn, | ||
attributes: attributesToAdd, | ||
controls, | ||
}); | ||
const result = await this._send(req); | ||
if (result.status !== MessageResponseStatus_1.MessageResponseStatus.Success) { | ||
throw StatusCodeParser_1.StatusCodeParser.parse(result.status); | ||
} | ||
} | ||
/** | ||
* Compares an attribute/value pair with an entry on the LDAP server. | ||
@@ -108,3 +156,2 @@ * @param {string} dn - The DN of the entry to compare attributes with | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -140,3 +187,2 @@ async compare(dn, attribute, value, controls) { | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -166,3 +212,2 @@ async del(dn, controls) { | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -193,13 +238,35 @@ async exop(oid, value, controls) { | ||
/** | ||
* Performs an LDAP modify against the server. | ||
* @param {string} dn - The DN of the entry to modify | ||
* @param {Change|Change[]} changes | ||
* @param {Control|Control[]} [controls] | ||
*/ | ||
async modify(dn, changes, controls) { | ||
if (!this.connected) { | ||
await this._connect(); | ||
} | ||
if (changes && !Array.isArray(changes)) { | ||
// tslint:disable-next-line:no-parameter-reassignment | ||
changes = [changes]; | ||
} | ||
if (controls && !Array.isArray(controls)) { | ||
// tslint:disable-next-line:no-parameter-reassignment | ||
controls = [controls]; | ||
} | ||
const req = new ModifyRequest_1.ModifyRequest({ | ||
messageId: this._nextMessageId(), | ||
dn, | ||
changes, | ||
controls, | ||
}); | ||
const result = await this._send(req); | ||
if (result.status !== MessageResponseStatus_1.MessageResponseStatus.Success) { | ||
throw StatusCodeParser_1.StatusCodeParser.parse(result.status); | ||
} | ||
} | ||
/** | ||
* Performs an LDAP modifyDN against the server. | ||
* | ||
* This does not allow you to keep the old DN, as while the LDAP protocol | ||
* has a facility for that, it's stupid. Just Search/Add. | ||
* | ||
* This will automatically deal with "new superior" logic. | ||
* | ||
* @param {string} dn - The DN of the entry to modify | ||
* @param {string} newDN - The new DN to move this entry to | ||
* @param {Control|Control[]} [controls] | ||
* @param controls | ||
*/ | ||
@@ -206,0 +273,0 @@ async modifyDN(dn, newDN, controls) { |
{ | ||
"name": "ldapts", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "LDAP client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254715
268
4099