Skip to content

Add

Adds a new delegation from one identity to another and returns the ID of the delegation.

$Delegation.Add(from: ( string | Identity ), to: ( string | Identity ), start: DateTimeOffset, end: DateTimeOffset):string (Identity, DateTimeOffset)

Parameters

( string | Identity ) from
    The delegating identity (ID or Identity object).

( string | Identity ) to
    The delegated identity (ID or Identity object).

DateTimeOffset start
    The start date and time of the delegation.

DateTimeOffset end
    The end date and time of the delegation.

Returns

The ID of the created delegation entry.

Remarks

The delegating identity must be a user. The target can be a user or position; both identities must resolve in the current security context. Adding a delegation persists it immediately.

Example

1
2
var delegationId = $Delegation.Add($ActiveUser, "target-user-id",
    DateTimeOffset.now, $Calendar.AddDays(DateTimeOffset.now, 5));