Directory
Public surface of the platform Directory service. JSDoc on this interface drives the generated API reference documentation.
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.
Methods¶
getGroupMembership()¶
getGroupMembership(
userId:string,groupIds:string[],organizationId: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/platform).
Parameters¶
| Parameter | Type | Description |
|---|---|---|
userId |
string |
GUID of the user to check |
groupIds |
string[] |
GUIDs of the groups to check against |
organizationId |
string |
Organization (account) GUID the user and groups belong to |
Returns¶
Promise<PlatformDirectoryGroup[]>
The groups the user belongs to, as PlatformDirectoryGroup items
Example¶
const memberships = await directory.getGroupMembership(
'<userId>',
['<adminGroupId>'],
'<organizationId>'
);
const isAdmin = memberships.length > 0;
search()¶
search(
organizationId:string,options?:PlatformDirectorySearchOptions):Promise<PlatformDirectoryEntry[]>
Searches the organization's principals.
Returns users, groups, and applications matching the options, from both local and external-directory sources.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
organizationId |
string |
Organization (account) GUID to search in |
options? |
PlatformDirectorySearchOptions |
Search filters |
Returns¶
Promise<PlatformDirectoryEntry[]>
The matching principals, as PlatformDirectoryEntry items
Examples¶
import { UiPath } from '@uipath/uipath-typescript/core';
import { Directory } from '@uipath/uipath-typescript/platform';
const sdk = new UiPath(config);
await sdk.initialize();
const directory = new Directory(sdk);
const results = await directory.search('<organizationId>', { startsWith: 'sar' });
for (const entry of results) {
console.log(`${entry.displayName} (${entry.type})`);
}