Skip to content

IAdmGroup

The IAdmGroup interface extends the IADsGroup interface to provide a more comprehensive option to access members of a group.

Inheritance: The IAdmGroup interface inherits from the IADsGroup interface.

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 direct members and members of the groups that are nested within this group.

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 other groups that are nested within this group. Each member GUID is represented as an array of 16 bytes (Byte[]), and the property itself is an array of arrays of bytes.

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

Remarks

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

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

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

# Bind to the group
$groupDN = "CN=HR Managers,CN=Groups,DC=domain,DC=com"
$group = $admService.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 = $admService.OpenObject($memberPath, $NULL, $NULL, 0)

    Write-Host "Member name:" $member.Get("name")
    Write-Host "Member type:" $member.Class
    Write-Host
}
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 adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the group
        const String groupPath = "Adaxes://CN=HR Managers,CN=Groups,DC=domain,DC=com";
        IAdmGroup group = (IAdmGroup) admService.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 = String.Format("Adaxes://<GUID={0}>", memberGuid);
            IADs member = (IADs) admService.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 members and members of the groups that are nested within this group. Each member GUID is represented as an array of 16 bytes (Byte[]), and the property itself is an array of arrays of bytes.

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

Remarks

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

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

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

# Bind to the group
$groupDN = "CN=Sales Managers,CN=Groups,DC=domain,DC=com"
$group = $admService.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 = $admService.OpenObject($memberPath, $NULL, $NULL, 0)

    Write-Host "Member name:" $member.Get("name")
    Write-Host "Member type:" $member.Class
    Write-Host
}
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 adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the group
        const String groupPath = "Adaxes://CN=Sales Managers,CN=Groups,DC=domain,DC=com";
        IAdmGroup group = (IAdmGroup) admService.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 = String.Format("Adaxes://<GUID={0}>", memberGuid);
            IADs member = (IADs) admService.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