Skip to content

IAdmGroup2

The IAdmGroup2 interface extends the IAdmGroup interface with the ability to change the type of group membership and manage rule-based groups.

Inheritance: The IAdmGroup2 interface inherits from the IAdmGroup interface.

Methods

Properties

Details

IsGroupMembershipUpdating()

Returns a value indicating whether group membership update is in progress.

Boolean IsGroupMembershipUpdating()

Remarks

If the MembershipType property is set to ADM_GROUPMEMBERSHIPTYPE_ASSIGNED, the method returns FALSE.


UpdateMembershipNow()

Initiates asynchronous update of group membership.

void UpdateMembershipNow()

Examples

The following code sample initiates asynchronous update of group membership.

[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=My Group,OU=Groups,DC=company,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Initiate group membership update
$group.UpdateMembershipNow()
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=My Group,OU=Groups,DC=company,DC=com";
        IAdmGroup2 group = (IAdmGroup2)admService.OpenObject(groupPath, null, null, 0);

        // Initiate group membership update
        group.UpdateMembershipNow();
    }
}

MembershipType

Gets or sets the type of group membership.

Remarks

  • To save the changes, call IADs::SetInfo after setting this property.
  • If this property is set to ADM_GROUPMEMBERSHIPTYPE_RULEBASED:

    • Members cannot be added/removed from the group using the IADsGroup::Add and IADsGroup::Remove methods.
    • The MembershipRules and MembershipUpdateSchedule properties must be specified.

Examples

The following code sample changes group membership type to rule-based, sets the schedule for updating group membership to every 2 hours and adds a membership rule to include the group owner.

[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=My Group,OU=Groups,DC=company,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Change membership type to rule-based
$group.MembershipType = "ADM_GROUPMEMBERSHIPTYPE_RULEBASED"

# Specify membership update schedule
$recurrencePattern = New-Object "Softerra.Adaxes.Adsi.AdmRecurrencePattern"
$recurrencePattern.RecurrenceType = "ADM_RECURRENCEPATTERNTYPE_HOURLY"
$recurrencePattern.Interval = 2
$group.MembershipUpdateSchedule = $recurrencePattern

# Add membership rule for group owner
$rules = $group.MembershipRules
$includeRule = $rules.Create("ADM_BUSINESSUNITMEMBERSHIPTYPE_OWNER")
$rules.Add($includeRule)
$group.MembershipRules = $rules

# Save the changes
$group.SetInfo()
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.BusinessUnits;
using Softerra.Adaxes.Interop.Adsi.ScheduledTasks;
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=My Group,OU=Groups,DC=company,DC=com";
        IAdmGroup2 group = (IAdmGroup2)admService.OpenObject(groupPath, null, null, 0);

        // Change membership type to rule-based
        group.MembershipType = ADM_GROUPMEMBERSHIPTYPE_ENUM.ADM_GROUPMEMBERSHIPTYPE_RULEBASED;

        // Specify membership update schedule
        IAdmRecurrencePattern recurrencePattern = new AdmRecurrencePattern();
        recurrencePattern.RecurrenceType =
                  ADM_RECURRENCEPATTERNTYPE_ENUM.ADM_RECURRENCEPATTERNTYPE_HOURLY;
        recurrencePattern.Interval = 2;
        group.MembershipUpdateSchedule = recurrencePattern;

        // Add membership rule for group owner
        IAdmBusinessUnitMembershipRules rules = group.MembershipRules;
        IAdmBusinessUnitMembershipRule includeRule =
              rules.Create(ADM_BUSINESSUNITMEMBERSHIPTYPE_ENUM.ADM_BUSINESSUNITMEMBERSHIPTYPE_OWNER);
        rules.Add(includeRule);
        group.MembershipRules = rules;

        // Save the changes
        group.SetInfo();
    }
}

MembershipRules

Gets or sets membership rules for the group.

Remarks

  • To save the changes, call IADs::SetInfo after setting this property.
  • Setting this property takes effect only if the MembershipType property is set to ADM_GROUPMEMBERSHIPTYPE_RULEBASED.

Examples

The following code sample adds a membership rule for including user John Smith into 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=My Group,OU=Groups,DC=company,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Add membership rule for user 'John Smith'
$userDN = "CN=John Smith,CN=Users,DC=company,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)
$rules = $group.MembershipRules
$includeRule = $rules.Create("ADM_BUSINESSUNITMEMBERSHIPTYPE_SPECIFIC")
$includeRule.Exclude = $False
$includeRule.Object = $user
$rules.Add($includeRule)
$group.MembershipRules = $rules

# Save the changes
$group.SetInfo()
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.BusinessUnits;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi;
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=My Group,OU=Groups,DC=company,DC=com";
        IAdmGroup2 group = (IAdmGroup2)admService.OpenObject(groupPath, null, null, 0);

        // Add membership rule for user 'John Smith'
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=company,DC=com";
        IAdmTop user = (IAdmTop)admService.OpenObject(userPath, null, null, 0);
        IAdmBusinessUnitMembershipRules rules = group.MembershipRules;
        IAdmBusinessUnitSpecificObjectRule includeRule = 
            (IAdmBusinessUnitSpecificObjectRule)rules.Create(
              ADM_BUSINESSUNITMEMBERSHIPTYPE_ENUM.ADM_BUSINESSUNITMEMBERSHIPTYPE_SPECIFIC);
        includeRule.Exclude = false;
        includeRule.Object = user;
        rules.Add(includeRule);
        group.MembershipRules = rules;

        // Save the changes
        group.SetInfo();
    }
}

MembershipUpdateSchedule

Gets or sets a recurrence pattern that represents the schedule for updating group membership.

Remarks

  • To save the changes, call IADs::SetInfo after setting this property.
  • Setting this property takes effect only if the MembershipType property is set to ADM_GROUPMEMBERSHIPTYPE_RULEBASED.

Examples

The following code sample sets the schedule for updating group membership to every day at 4:00 AM.

[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=My Group,OU=Groups,DC=company,DC=com"
$group = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

# Specify membership update schedule
$recurrencePattern = New-Object "Softerra.Adaxes.Adsi.AdmRecurrencePattern"
$recurrencePattern.RecurrenceType = "ADM_RECURRENCEPATTERNTYPE_DAILY"
$recurrencePattern.Interval = 1
$now = Get-Date
$recurrencePattern.PatternStartDateTime = Get-Date `
    -year $now.Year `
    -month $now.Month `
    -day $now.Day `
    -hour 4 `
    -minute 0 `
    -second 0
$group.MembershipUpdateSchedule = $recurrencePattern

# Save the changes
$group.SetInfo()
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.ScheduledTasks;
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=My Group,OU=Groups,DC=company,DC=com";
        IAdmGroup2 group = (IAdmGroup2)admService.OpenObject(groupPath, null, null, 0);

        // Specify membership update schedule
        IAdmRecurrencePattern recurrencePattern = new AdmRecurrencePattern();
        recurrencePattern.RecurrenceType =
                  ADM_RECURRENCEPATTERNTYPE_ENUM.ADM_RECURRENCEPATTERNTYPE_DAILY;
        recurrencePattern.Interval = 1;
        DateTime now = DateTime.Now;
        recurrencePattern.PatternStartDateTime = new DateTime(now.Year,
            now.Month, now.Day, 4, 0, 0);
        group.MembershipUpdateSchedule = recurrencePattern;

        // Save the changes
        group.SetInfo();
    }
}

MembershipLastUpdateDateUtc

Gets the date and time when group membership was last updated.

  • Type:
  • DateTime
  • Access:
  • Read-only

MembershipLastUpdateDuration

Gets the duration of the last group membership update.

  • Type:
  • TimeSpan
  • Access:
  • Read-only

Requirements

Minimum required version: 2020.1

See also