Skip to content

IAdmBusinessRule3

The IAdmBusinessRule3 interface extends the IAdmBusinessRule interface.

Inheritance: The IAdmBusinessRule3 interface inherits from the IAdmBusinessRule2 interface.

Methods

Details

FindAffectedObjects()

Returns the IAdmDirectorySearch interface that can be used to find all directory objects that are affected by the Business Rule or Scheduled Task.

IAdmDirectorySearch FindAffectedObjects()

Examples

The following code sample outputs all Active Directory objects affected by a Business Rule.

[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 Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(`
  "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
  $businessRulesPath
$myRuleAdsPath = $businessRulesPathObj.CreateChildPath(`
  "CN=My Rule")

$rule = $admService.OpenObject($myRuleAdsPath, $NULL, $NULL, 0)

# Retrieve the IAdmDirectorySearch 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()
}
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 adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the Business Rule
        String businessRulesPath = admService.Backend.GetConfigurationContainerPath(
            "BusinessRules");
        AdsPath businessRulesPathObj = new AdsPath(businessRulesPath);
        AdsPath myRuleAdsPath = businessRulesPathObj.CreateChildPath("CN=My Rule");

        IAdmBusinessRule3 rule =
            (IAdmBusinessRule3)admService.OpenObject(myRuleAdsPath.ToString(), null, null, 0);

        // Retrieve the IAdmDirectorySearch 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();
            }
        }
    }
}

Requirements

Minimum required version: 2011.3

See also