simple-ad
Version:
Basic ldapjs wrapper for reading and writing AD objects. Currently only searching and editing of group members is implemented.
83 lines (82 loc) • 2.22 kB
TypeScript
import ldap from 'ldapjs';
/**
* ActiveDirectory LDAP Options
* @typedef {Object} ActiveDirectoryOptions - LDAP Options
*/
interface ActiveDirectoryOptions {
url: string;
tlsOptions: Object;
username: string;
password: string;
clientOptions: ldap.ClientOptions;
}
/**
* Group modify operations
* @type {('add'|'delete')} Available modify operations
*/
type ModifyOperation = 'add' | 'delete';
/**
* Creates a new LDAP client
* @class ActiveDirectory
*/
export default class ActiveDirectory {
#private;
url: string;
tlsOptions: Object;
username: string;
clientOptions: ldap.ClientOptions;
client: any;
constructor(options: ActiveDirectoryOptions);
/**
* Bind to the LDAP Server
*/
bind(): Promise<void>;
/**
* Unbind the connection
*/
unbind(): Promise<void>;
/**
* Perform a LDAP search: http://ldapjs.org/client.html#search
* @param dn
* @param options
*/
search(dn: string, options: object): Promise<any[]>;
/**
* Find Group objects
* @param dn
* @param attributes ['cn', 'dn', 'member']
*/
findGroup(groupDN: string, attributes: string[]): Promise<any>;
/**
* Check if entry is member in group
* @param groupDN
* @param memberDN
*/
isGroupMember(groupDN: string, memberDN: string): Promise<boolean>;
/**
* Add or delete group members
* @param groupDN
* @param members
* @param operation
*/
modifyGroupMember(groupDN: string, members: string | string[], operation: ModifyOperation): Promise<void>;
/**
* Delete one group member
* @param groupDN
* @param memberDN
*/
addGroupMember(groupDN: string, memberDN: string): Promise<void>;
/**
* Remove one group member
* @param groupDN
* @param memberDN
*/
deleteGroupMember(groupDN: string, memberDN: string): Promise<void | null>;
/**
* Find a user objects
* @param dn
* @param attributes ['cn', 'dn', 'memberOf']
*/
findUser(userDN: string, attributes: string[]): Promise<any>;
}
export {};