import { SearchOptions } from 'ldapts'; export interface LdapConfig { url: string; bindDn: string; password: string; timeout?: number; tlsOptions?: { rejectUnauthorized?: boolean; ca?: string; }; isSecure?: boolean; hostType?: string; } /** * Escapes special characters in an LDAP DN */ export declare function escapeDN(str: string): string; /** * Validates a sAMAccountName (max 20 chars, no spaces or special characters) */ export declare function validateSAMAccountName(sam: string): { valid: boolean; error?: string; }; /** * Validates a UPN (User Principal Name) */ export declare function validateUPN(upn: string): { valid: boolean; error?: string; }; export declare class AdClient { private client; private baseDn; private config; constructor(config: LdapConfig, baseDn: string); bind(bindDn: string, password: string): Promise; unbind(): Promise; /** * Reconnects the client in case of error */ private reconnect; add(dn: string, entry: Record): Promise; modify(dn: string, changes: any): Promise; search(base: string, options: SearchOptions): Promise; /** * Sets AD password (unicodePwd) - REQUIRES LDAPS */ setPassword(dn: string, newPassword: string): Promise; /** * Enables a user (removes the ACCOUNTDISABLE flag) */ enableUser(dn: string): Promise; /** * Disables a user (adds the ACCOUNTDISABLE flag) */ disableUser(dn: string): Promise; /** * Checks if a user is a member of a group */ isGroupMember(userDn: string, groupDn: string): Promise; /** * Searches for a user by sAMAccountName */ findUserBySAM(samAccountName: string): Promise; /** * Retrieves a user with all properties */ getUserBySAM(samAccountName: string, includeAll?: boolean): Promise; /** * Lists users with advanced filters */ listUsers(options?: { filterType?: string; searchValue?: string; searchField?: string; includeAll?: boolean; maxResults?: number; }): Promise; /** * Retrieves all groups of a user */ getUserGroups(samAccountName: string, includeNested?: boolean, fullDetails?: boolean): Promise; /** * Retrieves user activity information */ getUserActivity(samAccountName: string, activityType?: string): Promise; /** * Unlocks a user account */ unlockUserAccount(samAccountName: string): Promise; /** * Checks password expiration */ checkPasswordExpiry(samAccountName: string): Promise; /** * Creates an Organizational Unit */ createOU(name: string, parentDn: string, description?: string): Promise; /** * Gets an Organizational Unit by DN */ getOU(dn: string): Promise; /** * Modifies an Organizational Unit */ modifyOU(dn: string, attributes: Record): Promise; /** * Deletes an Organizational Unit (must be empty) */ deleteOU(dn: string): Promise; /** * Lists Organizational Units */ listOUs(parentDn?: string, searchFilter?: string): Promise; /** * Creates a Group (Security or Distribution) */ createGroup(name: string, parentDn: string, options?: { groupType?: 'security' | 'distribution'; scope?: 'global' | 'domainLocal' | 'universal'; description?: string; samAccountName?: string; }): Promise; /** * Gets a Group by DN */ getGroup(dn: string): Promise; /** * Modifies a Group */ modifyGroup(dn: string, attributes: Record): Promise; /** * Deletes a Group */ deleteGroup(dn: string): Promise; /** * Lists Groups with filters */ listGroups(options?: { searchFilter?: string; groupType?: 'security' | 'distribution' | 'all'; scope?: 'global' | 'domainLocal' | 'universal' | 'all'; maxResults?: number; }): Promise; /** * Searches groups by name (for autocomplete/dropdown) */ searchGroups(searchTerm: string, maxResults?: number): Promise>; /** * Searches OUs by name (for autocomplete/dropdown) */ searchOUs(searchTerm: string, maxResults?: number): Promise>; }