IAdmUser2
The IAdmUser2 interface extends the IAdmUser interface with the GetRequestsForApproval2 and GetApprovals2 methods. These methods allow retrieving a list of approval requests that are either initiated by or submitted for approval to a user during a given period of time.
Inheritance: IAdmUser
Derived: IAdmUser3
Methods
-
Method
-
Description
-
GetRequestsForApproval2()
-
Returns an array of GUIDs of approval requests initiated by the user during the given period of time.
-
GetApprovals2()
-
Returns an array of GUIDs of the approval requests that were approved, denied, cancelled, or awaiting approval by the user.
Details
GetRequestsForApproval2()
Returns an array of GUIDs of approval requests initiated by the user during the given period of time.
object GetRequestsForApproval2(ADM_APPROVALSTATE_ENUM requestState,
DateTime dateFrom,
DateTime dateTo)
Parameters
- requestState – the request state which controls whether the method returns approved, denied, cancelled, or pending approval requests.
- dateFrom – the start date and time. The method will return approval requests initiated after the specified date/time.
- dateTo – the end date and time. The method will return approval requests initiated before the specified date/time.
Return value
The method returns an array of approval request GUIDs. Each GUID is represented as an array of 16 bytes (Byte[]), and the return value is an array of byte arrays (Byte[][]).
You can bind to approval request objects by their GUIDs. For more information on how to bind to directory objects, see Binding to ADSI objects. Each approval request is represented by the IAdmApprovalRequest interface.
Examples
The following code sample outputs information about pending approval requests initiated by a specific user during the last 10 days.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $numDays = 10 # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to the user. $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Get pending approval requests initiated by the user during the requested time period. $startDateTime = (Get-Date).AddDays(-$numDays) $endDateTime = Get-Date $approvalRequestGuids = $user.GetRequestsForApproval2( "ADM_APPROVALSTATE_PENDING", $startDateTime, $endDateTime) foreach ($requestGuidBytes in $approvalRequestGuids) { # Bind to the approval request. $requestGuid = [Guid]$requestGuidBytes $requestPath = "Adaxes://<Guid=$requestGuid>" $request = $service.OpenObject($requestPath, $null, $null, 0) # Output information about the approval request. Write-Host "Operation:" $request.DescriptionOfOperationToApprove Write-Host "Requested on" $request.CreationDate.ToShortDateString() Write-Host } - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.ApprovalRequests; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { const string userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"; const int numDays = 10; // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the user. IAdmUser2 user = (IAdmUser2)service.OpenObject($"Adaxes://{userDN}", null, null, 0); // Get pending approval requests initiated by the user during the requested time period. DateTime startDateTime = DateTime.Now.AddDays(-numDays); DateTime endDateTime = DateTime.Now; object[] approvalRequestGuids = (object[])user.GetRequestsForApproval2( ADM_APPROVALSTATE_ENUM.ADM_APPROVALSTATE_PENDING, startDateTime, endDateTime); foreach (Byte[] requestGuidBytes in approvalRequestGuids) { // Bind to the approval request. string requestGuid = new Guid(requestGuidBytes).ToString("B"); string requestPath = $"Adaxes://<GUID={requestGuid}>"; IAdmApprovalRequest request = (IAdmApprovalRequest)service.OpenObject( requestPath, null, null, 0); // Output information about the approval request. Console.WriteLine("Operation: {0}", request.DescriptionOfOperationToApprove); Console.WriteLine("Requested on {0}", request.CreationDate.ToShortDateString()); Console.WriteLine(); } } }
GetApprovals2()
Returns an array of GUIDs of the approval requests that were approved, denied, cancelled, or awaiting approval by the user. Unlike the IAdmUser::GetApprovals method, this method returns only approval requests initiated during the given period of time. If the method is called to get pending requests, the time period is ignored.
object GetApprovals2(ADM_APPROVALSTATE_ENUM requestState,
DateTime dateFrom,
DateTime dateTo)
Parameters
- requestState – the request state which controls whether the method returns approved, denied, cancelled, or pending approval requests.
- dateFrom – the start date and time. The method will return approval requests initiated after the specified date/time.
- dateTo – the end date and time. The method will return approval requests initiated before the specified date/time.
Return value
The method returns an array of approval request GUIDs. Each GUID is represented as an array of 16 bytes (Byte[]), and the return value is an array of byte arrays (Byte[][]).
You can bind to approval request objects by their GUIDs. For more information on how to bind to directory objects, see Binding to ADSI objects. Each approval request is represented by the IAdmApprovalRequest interface.
Examples
The following code sample outputs information about approval requests initiated during last 10 days and denied by a specific user.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $numDays = 10 # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to the user. $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Get approval requests initiated during the specified time period and denied by the user. $startDateTime = (Get-Date).AddDays(-$numDays) $endDateTime = Get-Date $approvalRequestGuids = $user.GetApprovals2( "ADM_APPROVALSTATE_DENIED", $startDateTime, $endDateTime) foreach ($requestGuidBytes in $approvalRequestGuids) { # Bind to the approval request. $requestGuid = [Guid]$requestGuidBytes $requestPath = "Adaxes://<Guid=$requestGuid>" $request = $service.OpenObject($requestPath, $null, $null, 0) # Output information about the approval request. Write-Host "Target object:" $request.TargetObject.Name Write-Host "Operation:" $request.DescriptionOfOperationToApprove Write-Host "Reason for denial:" $request.DenialOrCancelingReason Write-Host } - C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.ApprovalRequests; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { const string userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"; const int numDays = 10; // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the user. IAdmUser2 user = (IAdmUser2)service.OpenObject($"Adaxes://{userDN}", null, null, 0); // Get approval requests initiated during the specified time period and denied by the user. DateTime startDateTime = DateTime.Now.AddDays(-numDays); DateTime endDateTime = DateTime.Now; object[] approvalRequestGuids = (object[])user.GetApprovals2( ADM_APPROVALSTATE_ENUM.ADM_APPROVALSTATE_DENIED, startDateTime, endDateTime); foreach (Byte[] requestGuidBytes in approvalRequestGuids) { // Bind to the approval request. string requestGuid = new Guid(requestGuidBytes).ToString("B"); string requestPath = $"Adaxes://<GUID={requestGuid}>"; IAdmApprovalRequest request = (IAdmApprovalRequest)service.OpenObject( requestPath, null, null, 0); // Output information about the approval request. Console.WriteLine("Target object: {0}", request.TargetObject.Name); Console.WriteLine("Operation: {0}", request.DescriptionOfOperationToApprove); Console.WriteLine("Reason for denial: {0}", request.DenialOrCancelingReason); Console.WriteLine(); } } }
Requirements
Minimum required version: 2013.1