IAdmGroup
The IAdmGroup interface extends the IADsGroup interface to provide a more comprehensive option to access members of a group.
Inheritance: IADsGroup
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.
- 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 = string.Format("Adaxes://<GUID={0}>", 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 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.
- 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 = string.Format("Adaxes://<GUID={0}>", 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