Skip to content

IADsGroup

The IADsGroup interface is designed to manage group membership data. It enables you to get member objects, test if a given object belongs to the group, and to add, or remove, an object to, or from, the group.

Inheritance: The IADsGroup interface inherits from the IADs interface.

Methods

  • Method

  • Description

  • Add()

  • Adds an ADSI object to the group.

  • IsMember()

  • Determines if a directory service object is an immediate member of the group.

  • Members()

  • Retrieves a collection of the immediate members of the group.

  • Remove()

  • Removes the specified member from this group.

Properties

Details

Add()

Adds an ADSI object to the group.

void Add(String newObject)

Parameters

The newObject parameter specifies the ADS path of the object to add to the group.

Examples

The following code sample adds user John Smith to the SalesGroup group.

[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=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Add user 'John Smith' to group 'SalesGroup'
$userDN ="CN=John Smith,CN=Users,DC=domain,DC=com"
$group.Add("Adaxes://$userDN")
using Softerra.Adaxes.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=SalesGroup,CN=Users,DC=domain,DC=com";
        IADsGroup group = (IADsGroup)admService.OpenObject(
            groupPath, null, null, 0);

        // Add user 'John Smith' to group 'SalesGroup'
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        group.Add(userPath);
    }
}

IsMember()

Determines if a directory service object is an immediate member of the group. This method does not verify membership in nested groups.

Boolean IsMember(String member)

Parameters

The member parameter specifies the ADS path of the directory object to verify membership.

Remarks

The method will only work correctly if the group and the object are in the same domain. If the object is in a different domain than the group, this method always returns FALSE. If the group and the object are in different domains, use the IAdmGroup interface.

Examples

The following code sample adds user John Smith to the SalesGroup group and then reports that the user is now a member of the group.

[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=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Add user 'John Smith' to group 'SalesGroup'
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$group.Add("Adaxes://$userDN")

# Report that the user is now a member of the group
Write-Host $group.IsMember("Adaxes://$userDN") # should be TRUE
using System;
using Softerra.Adaxes.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=SalesGroup,CN=Users,DC=domain,DC=com";
        IADsGroup group = (IADsGroup)admService.OpenObject(
            groupPath, null, null, 0);

        // Add user 'John Smith' to group 'SalesGroup'
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        group.Add(userPath);

        // Report that the user is now a member of the group
        Console.WriteLine(group.IsMember(userPath)); // should be TRUE
    }
}

Members()

Retrieves a collection of the immediate members of the group. The collection does not include the members of other groups that are nested within the group. If you want to get a collection of all members, including members of the nested groups, use the IAdmGroup interface.

IADsMembers Members()

Examples

The following code sample enumerates all members of a group.

[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=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Enumerate all members of the group
foreach($member in $group.Members())
{
    Write-Host $member.Name
}
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=SalesGroup,CN=Users,DC=domain,DC=com";
        IADsGroup group = (IADsGroup)admService.OpenObject(
            groupPath, null, null, 0);

        // Enumerate all members of the group
        foreach (IADs member in group.Members())
        {
            Console.WriteLine(member.Name);
        }
    }
}

Remove()

Removes the specified member from this group. The operation does not remove the group object itself even when there is no member remaining in the group.

void Remove(String objectToRemove)

Parameters

The objectToRemove parameter specifies the ADS path of the object to remove from the group.

Examples

The following code sample removes a user account from a group.

[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 target group
$groupDN = "CN=SalesGroup,CN=Users,DC=domain,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Remove a user account from a group
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$group.Remove("Adaxes://$userDN")
using Softerra.Adaxes.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 target group
        const string groupPath = "Adaxes://CN=SalesGroup,CN=Users,DC=domain,DC=com";
        IADsGroup group = (IADsGroup)admService.OpenObject(
            groupPath, null, null, 0);

        // Remove a user account from a group
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        group.Remove(userPath);
    }
}

Description

Gets or sets the description of the group.

  • Type:
  • String
  • Access:
  • Read/Write

Requirements

Minimum required version: 2009.1

See also