Skip to content

IAdmUser2

The IAdmUser2 interface extends the IAdmUser interface with the GetRequestsForApproval2 and GetApprovals2 methods. The 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: The IAdmUser2 interface inherits from the IAdmUser interface.

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 still awaiting for 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 - Specifies whether the method returns approved, denied, cancelled, or pending approval requests.
  • dateFrom – Specifies the start date and time. The method will return approval requests initiated after the specified date/time.
  • dateTo – Specifies 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 itself is an array of arrays of bytes.

Using the GUIDs, you can bind to approval request objects. 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 last 10 days.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$numDays = 10

# Connect to the Adaxes service
$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$user = $admService.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 = $admService.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
}
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 Int32 numDays = 10;

        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmUser2 user = (IAdmUser2)admService.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 = String.Format("Adaxes://<GUID={0}>", requestGuid);
            IAdmApprovalRequest request = (IAdmApprovalRequest)admService.OpenObject(
                requestPath, null, null, 0);

            // Output information about the approval request
            Console.WriteLine("Operation: " + request.DescriptionOfOperationToApprove);
            Console.WriteLine("Requested on " + request.CreationDate.ToShortDateString());
            Console.WriteLine(String.Empty);
        }
    }
}

GetApprovals2()

Returns an array of GUIDs of the approval requests that were approved, denied, cancelled, or still awaiting for 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 - Controls whether the method returns approved, denied, cancelled, or pending approval requests.
  • dateFrom – Specifies the start date and time. The method will return approval requests initiated after the specified date/time.
  • dateTo – Specifies 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 itself is an array of arrays of bytes.

Using the GUIDs, you can bind to approval request objects. 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.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$numDays = 10

# Connect to the Adaxes service
$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the user
$user = $admService.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 = $admService.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
}
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 Int32 numDays = 10;

        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmUser2 user = (IAdmUser2)admService.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 = String.Format("Adaxes://<GUID={0}>", requestGuid);
            IAdmApprovalRequest request = (IAdmApprovalRequest)admService.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

See also