Skip to content

Directory

Public surface of the Directory service.

The directory is the lookup layer over an organization's principals — users, groups, and applications, whether local or provisioned from an external directory. Use it to find principals by name and to answer membership questions ("is this user in the Administrators group?") without listing whole groups.

Usage

Prerequisites: Initialize the SDK first - see Getting Started

import { Directory } from '@uipath/uipath-typescript/directory';

const directory = new Directory(sdk);
const results = await directory.search('sar');

Methods

getGroupMembership()

getGroupMembership(userId: string, groupIds: string[]): Promise<PlatformDirectoryGroup[]>

Checks which of the given groups a user belongs to.

Returns the subset of groupIds the user is a member of — the membership check behind "does this user hold the admin group?". An empty array means the user is in none of them.

First, get group IDs with groups.getAll() (from @uipath/uipath-typescript/groups).

Parameters

Parameter Type Description
userId string GUID of the user to check
groupIds string[] GUIDs of the groups to check against

Returns

Promise<PlatformDirectoryGroup[]>

The groups the user belongs to, as PlatformDirectoryGroup items

Example

import { UiPath } from '@uipath/uipath-typescript/core';
import { Directory } from '@uipath/uipath-typescript/directory';

const sdk = new UiPath(config);
await sdk.initialize();

const directory = new Directory(sdk);
const memberships = await directory.getGroupMembership('<userId>', ['<adminGroupId>']);
const isAdmin = memberships.length > 0;

search(startsWith: string, options?: PlatformDirectorySearchOptions): Promise<PlatformDirectoryEntry[]>

Searches the organization's principals by name prefix.

Returns users, groups, and applications whose name starts with the text, from both local and external-directory sources. The prefix is required (one character is enough); every match comes back in a single response — the results are not paged.

Parameters

Parameter Type Description
startsWith string Name prefix to match
options? PlatformDirectorySearchOptions Narrow the results by principal kind or source

Returns

Promise<PlatformDirectoryEntry[]>

The matching principals, as PlatformDirectoryEntry items

Examples

import { UiPath } from '@uipath/uipath-typescript/core';
import { Directory } from '@uipath/uipath-typescript/directory';

const sdk = new UiPath(config);
await sdk.initialize();

const directory = new Directory(sdk);
const results = await directory.search('sar');
import { PlatformDirectoryEntityType } from '@uipath/uipath-typescript/directory';

const groups = await directory.search('Admin', {
  entityType: PlatformDirectoryEntityType.Group,
});