IAdmGroup2
The IAdmGroup2 interface extends the IAdmGroup interface with the ability to change the type of group membership and manage rule-based groups.
Inheritance: IAdmGroup
Methods
-
Method
-
Description
-
IsGroupMembershipUpdating()
-
Returns a value indicating whether group membership update is in progress.
-
UpdateMembershipNow()
-
Initiates asynchronous update of group membership.
Properties
-
Property
-
Description
-
MembershipType
-
Gets or sets the type of group membership.
-
MembershipRules
-
Gets or sets membership rules for the group.
-
MembershipUpdateSchedule
-
Gets or sets a recurrence pattern that represents the schedule for updating group membership.
-
MembershipLastUpdateDateUtc
-
Gets the date and time when group membership was last updated.
-
MembershipLastUpdateDuration
-
Gets the duration of the last group membership update.
Details
IsGroupMembershipUpdating()
Returns a value indicating whether group membership update is in progress.
bool 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.
- 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=My Group,OU=Groups,DC=company,DC=com" $group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0) # Initiate group membership update $group.UpdateMembershipNow()
- C#
-
using Softerra.Adaxes.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=My Group,OU=Groups,DC=company,DC=com"; IAdmGroup2 group = (IAdmGroup2)service.OpenObject(groupPath, null, null, 0); // Initiate group membership update group.UpdateMembershipNow(); } }
MembershipType
Gets or sets the type of group membership.
- Type:
- ADM_GROUPMEMBERSHIPTYPE_ENUM
- Access:
- Read/Write
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
andMembershipUpdateSchedule
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.
- 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=My Group,OU=Groups,DC=company,DC=com" $group = $service.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()
- C#
-
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 ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the group const string groupPath = "Adaxes://CN=My Group,OU=Groups,DC=company,DC=com"; IAdmGroup2 group = (IAdmGroup2)service.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.
- Type:
- IAdmBusinessUnitMembershipRules
- Access:
- Read/Write
Remarks
- To save the changes, call IADs::SetInfo after setting this property.
- Setting this property takes effect only if the
MembershipType
property is set toADM_GROUPMEMBERSHIPTYPE_RULEBASED
.
Examples
The following code sample adds a membership rule for including user John Smith into the group.
- 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=My Group,OU=Groups,DC=company,DC=com" $group = $service.OpenObject("Adaxes://$groupDN", $null, $null, 0) # Add membership rule for user 'John Smith' $userDN = "CN=John Smith,CN=Users,DC=company,DC=com" $user = $service.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()
- C#
-
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 ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the group const string groupPath = "Adaxes://CN=My Group,OU=Groups,DC=company,DC=com"; IAdmGroup2 group = (IAdmGroup2)service.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)service.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.
- Type:
- IAdmRecurrencePattern
- Access:
- Read/Write
Remarks
- To save the changes, call IADs::SetInfo after setting this property.
- Setting this property takes effect only if the
MembershipType
property is set toADM_GROUPMEMBERSHIPTYPE_RULEBASED
.
Examples
The following code sample sets the schedule for updating group membership to every day at 4:00 AM.
- 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=My Group,OU=Groups,DC=company,DC=com" $group = $service.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()
- C#
-
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 ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the group const string groupPath = "Adaxes://CN=My Group,OU=Groups,DC=company,DC=com"; IAdmGroup2 group = (IAdmGroup2)service.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