IAdmBusinessRule
The IAdmBusinessRule interface represents a business rule, custom command, or scheduled task.
Inheritance: IAdmTop
Methods
-
Method
-
Description
-
IsInScope()
-
Checks whether the given directory object is affected by the business rule.
-
FindAffectedObjects()
-
Returns the IAdmDirectorySearcher interface that can be used to find all directory objects that are affected by the business rule or scheduled task.
-
GetBusinessRulesInExecutionOrder()
-
Returns an array of business rules with the same triggering operation, object type and execution moment.
Properties
-
Property
-
Description
-
RuleName
-
Gets the name of the business rule.
-
Description
-
Gets or sets an optional description for the business rule.
-
ObjectType
-
Gets or sets the type of directory objects to which the business rule is applied.
-
AdditionalObjectType
-
Gets or sets an additional type of directory objects to which the business rule, custom command, or scheduled task is applied.
-
OperationType
-
Gets or sets the type of the operation that will trigger the business rule.
-
ExecutionMoment
-
Gets or sets a value that indicates when the business rule is to be executed.
-
ConditionedActions
-
Gets conditions and actions defined for the business rule.
-
ActivityScopeItems
-
Gets a collection of scope items that represent the activity scope of the business rule.
-
Disabled
-
Gets or sets a value that indicates whether the business rule is disabled.
Details
IsInScope()
Checks whether the given directory object is affected by the business rule.
bool IsInScope(IAdmTop object)
Parameters
The object parameter is the directory object to be checked.
Examples
The following code sample checks whether a user is affected by a business rule.
- 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 user $userDN = "CN=John Smith,CN=Users,DC=domain,DC=com" $user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0) # Bind to the business rule $businessRulesPath = $service.Backend.GetConfigurationContainerPath("BusinessRules") $businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $businessRulesPath $myRuleAdsPath = $businessRulesPathObj.CreateChildPath("CN=My Rule") $rule = $service.OpenObject($myRuleAdsPath, $null, $null, 0) if ($rule.IsInScope($user)) { Write-Host "The business rule affects" $user.Get("name") } else { Write-Host "The business rule does not affect" $user.Get("name") }
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.BusinessRules; 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 user const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com"; IAdmTop user = (IAdmTop) service.OpenObject(userPath, null, null, 0); // Bind to the business rule string businessRulesPath = service.Backend.GetConfigurationContainerPath( "BusinessRules"); AdsPath businessRulesPathObj = new AdsPath(businessRulesPath); AdsPath myRuleAdsPath = businessRulesPathObj.CreateChildPath("CN=My Rule"); IAdmBusinessRule rule = (IAdmBusinessRule) service.OpenObject(myRuleAdsPath.ToString(), null, null, 0); if (rule.IsInScope(user)) { Console.WriteLine("The business rule affects {0}", user.Get("name")); } else { Console.WriteLine("The business rule does not affect {0}", user.Get("name")); } } }
FindAffectedObjects()
Returns the IAdmDirectorySearcher interface that can be used to find all directory objects that are affected by the business rule or scheduled task.
IAdmDirectorySearcher FindAffectedObjects()
Examples
The following code sample outputs all directory objects affected by a business rule.
- 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 business rule $businessRulesPath = $service.Backend.GetConfigurationContainerPath("BusinessRules") $businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $businessRulesPath $myRuleAdsPath = $businessRulesPathObj.CreateChildPath("CN=My Rule") $rule = $service.OpenObject($myRuleAdsPath, $null, $null, 0) # Retrieve the IAdmDirectorySearcher interface that can be used to search for affected objects $affectedObjectsSeacher = $rule.FindAffectedObjects() # Set search parameters $affectedObjectsSeacher.PageSize = 500 $affectedObjectsSeacher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER" $affectedObjectsSeacher.SetPropertiesToLoad(@("description")) # Execute search try { $searchResult = $affectedObjectsSeacher.ExecuteSearch() # Output name and description of each object in search results foreach ($objectId in $searchResult.FetchAll()) { Write-Host "Name:" $objectId.Name Write-Host "Description:" $objectId.Properties["description"].Value Write-Host } } finally { $searchResult.Dispose() }
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi; using Softerra.Adaxes.Interop.Adsi.BusinessRules; 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 business rule string businessRulesPath = service.Backend.GetConfigurationContainerPath( "BusinessRules"); AdsPath businessRulesPathObj = new AdsPath(businessRulesPath); AdsPath myRuleAdsPath = businessRulesPathObj.CreateChildPath("CN=My Rule"); IAdmBusinessRule rule = (IAdmBusinessRule)service.OpenObject(myRuleAdsPath.ToString(), null, null, 0); // Retrieve the IAdmDirectorySearcher interface that can be used to search for affected objects IAdmDirectorySearcher affectedObjectsSeacher = (IAdmDirectorySearcher)rule.FindAffectedObjects(); // Set search parameters affectedObjectsSeacher.PageSize = 500; affectedObjectsSeacher.ReferralChasing = ADS_CHASE_REFERRALS_ENUM.ADS_CHASE_REFERRALS_NEVER; affectedObjectsSeacher.SetPropertiesToLoad(new string[] { "description" }); // Execute search using (IAdmSearchResultIterator searchResult = (IAdmSearchResultIterator)affectedObjectsSeacher.ExecuteSearch()) { // Output name and description of each object in search results foreach (AdmSearchResult objectId in searchResult.FetchAll()) { Console.WriteLine("Name: {0}", objectId.Name); Console.WriteLine("Description: {0}", objectId.Properties["description"].Value); Console.WriteLine(); } } } }
GetBusinessRulesInExecutionOrder()
Returns an array of business rules with the same triggering operation, object type and execution moment. Business rules in the array are sorted by their execution order.
IAdmBusinessRule[] GetBusinessRulesInExecutionOrder()
Remarks
If the user doesn't have the permission to view a business rule, the array returned by the method will contain null
for the rule.
RuleName
Gets the name of the business rule.
- Type:
- string
- Access:
- Read-only
Description
Gets or sets an optional description for the business rule.
- Type:
- string
- Access:
- Read/Write
ObjectType
Gets or sets the type of directory objects to which the business rule is applied. The property must be set to a string that contains the name of an object class as defined in your directory schema (e.g. "user", "group", "computer", "organizationalUnit", etc.).
- Type:
- string
- Access:
- Read/Write
Remarks
To specify an additional object type, use property AdditionalObjectType
.
AdditionalObjectType
Gets or sets an additional type of directory objects to which the business rule, custom command, or scheduled task is applied. The property must be set to a string that contains the name of an object class as defined in your directory schema (e.g. "user", "group", "computer", "organizationalUnit", etc.).
- Type:
- string
- Access:
- Read/Write
OperationType
Gets or sets the type of the operation that will trigger the business rule. List of possible values.
- Type:
- string
- Access:
- Read/Write
ExecutionMoment
Gets or sets a value that indicates when the business rule is to be executed. A business rule can be executed before or after the triggering operation.
- Type:
- ADM_BUSINESSRULEEXECMOMENT_ENUM
- Access:
- Read/Write
ConditionedActions
Gets conditions and actions defined for the business rule. Each item in the collection is a set of actions and conditions. A set of actions and conditions is represented by the IAdmBusinessRuleConditionedActions interface.
- Type:
- IAdmCollection
- Access:
- Read-only
ActivityScopeItems
Gets a collection of scope items that represent the activity scope of the business rule. A scope item is represented by the IAdmActivityScopeItem interface.
- Type:
- IAdmCollection
- Access:
- Read-only
Disabled
Gets or sets a value that indicates whether the business rule is disabled.
- Type:
- bool
- Access:
- Read/Write
Requirements
Minimum required version: 2023