IAdmGroup

The IAdmGroup interface extends the IADsGroup interface to provide more options to access group members.

Inheritance: IADsGroup

Derived: IAdmGroup2

Properties

  • Property

  • Description

  • DirectMembers

  • Gets an array of GUIDs of all objects that are direct members of the group.

  • AllMembers

  • Gets an array of GUIDs of all members of the group, including members of nested groups.

Details

DirectMembers

Gets an array of GUIDs of all objects that are direct members of the group. This property does not return GUIDs of any indirect members, i.e. members of groups nested within this group. Each GUID is represented as an array of 16 bytes (Byte[]), and the property is an array of byte arrays (Byte[][]).

  • Type:
  • Object
  • Access:
  • Read-only

Remarks

You can bind to objects by their GUIDs. For more information on how to bind to directory objects, see Binding to ADSI objects.

Examples

The following code sample outputs the list of direct members of a group, not including members of nested groups.

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

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

# Bind to the group.
$groupDN = "CN=HR Managers,CN=Groups,DC=domain,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# Get GUIDs of direct members of the group.
$memberGuidsBytes = $group.DirectMembers

# Enumerate direct members.
foreach ($memberGuidBytes in $memberGuidsBytes)
{
    # Bind to the member by GUID.
    $memberGuid = [Guid]$memberGuidBytes
    $memberPath = "Adaxes://<Guid=$memberGuid>"
    $member = $service.OpenObject($memberPath, $null, $null, 0)
    
    Write-Host "Member name:" $member.Get("name")
    Write-Host "Member type:" $member.Class
    Write-Host
}
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the group.
        const string groupPath = "Adaxes://CN=HR Managers,CN=Groups,DC=domain,DC=com";
        IAdmGroup group = (IAdmGroup)service.OpenObject(groupPath, null, null, 0);

        // Get GUIDs of direct members of the group.
        object[] memberGuidsBytes = (object[])group.DirectMembers;

        // Enumerate direct members.
        foreach (Byte[] memberGuidBytes in memberGuidsBytes)
        {
            // Bind to the member by GUID.
            string memberGuid = new Guid(memberGuidBytes).ToString("B");
            string memberPath = $"Adaxes://<GUID={memberGuid}>";
            IADs member = (IADs)service.OpenObject(memberPath, null, null, 0);

            Console.WriteLine("Member name: {0}", member.Get("name"));
            Console.WriteLine("Member type: {0}", member.Class);
            Console.WriteLine();
        }
    }
}

AllMembers

Gets an array of GUIDs of all members of the group, including direct and indirect members. Each GUID is represented as an array of 16 bytes (Byte[]), and the property is an array byte arrays (Byte[][]).

  • Type:
  • Object
  • Access:
  • Read-only

Remarks

You can bind to objects by their GUIDs. For more information on how to bind to directory objects, see Binding to ADSI objects.

Examples

The following code sample outputs the list of all members of a group, including members of nested groups.

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

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

# Bind to the group.
$groupDN = "CN=Sales Managers,CN=Groups,DC=domain,DC=com"
$group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0)

# Get GUIDs of all members of the group.
$memberGuidsBytes = $group.AllMembers

# Enumerate all members.
foreach ($memberGuidBytes in $memberGuidsBytes)
{
    # Bind to the member by GUID.
    $memberGuid = [Guid]$memberGuidBytes
    $memberPath = "Adaxes://<Guid=$memberGuid>"
    $member = $service.OpenObject($memberPath, $null, $null, 0)
    
    Write-Host "Member name:" $member.Get("name")
    Write-Host "Member type:" $member.Class
    Write-Host
}
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the group.
        const string groupPath = "Adaxes://CN=Sales Managers,CN=Groups,DC=domain,DC=com";
        IAdmGroup group = (IAdmGroup)service.OpenObject(groupPath, null, null, 0);

        // Get GUIDs of all members of the group.
        object[] memberGuidsBytes = (object[])group.AllMembers;

        // Enumerate all members.
        foreach (Byte[] memberGuidBytes in memberGuidsBytes)
        {
            // Bind to the member by GUID.
            string memberGuid = new Guid(memberGuidBytes).ToString("B");
            string memberPath = $"Adaxes://<GUID={memberGuid}>";
            IADs member = (IADs)service.OpenObject(memberPath, null, null, 0);

            Console.WriteLine("Member name: {0}", member.Get("name"));
            Console.WriteLine("Member type: {0}", member.Class);
            Console.WriteLine();
        }
    }
}

Requirements

Minimum required version: 2009.1

See also