Criteria

The Criteria class represents criteria for directory object queries. For details about accessing an instance of this class, see How to build criteria.

Implements: IAdmCriteria, IAdmConfigObjectJson

Namespace: Softerra.Adaxes.Directory.Criteria

Constructors

Methods

Properties

  • Property

  • Description

  • Item[string]

  • Gets the criteria items that apply to the specified object type.

Details

Criteria()

Initializes a new instance of the Criteria class.

Criteria()

Criteria(Dictionary<string, CompoundCriteriaItem>)

Initializes a new instance of the Criteria class with the specified object types and criteria items.

Criteria(Dictionary<string, CompoundCriteriaItem> objectTypes)

Parameters

The objectTypes parameter specifies a dictionary of object type names and corresponding criteria items. Object type names must exactly match the names of the corresponding object classes in your directory schema e.g. user, group.

Examples

The following code sample creates a criteria with criteria items for User and Group object types.

using Softerra.Adaxes.Directory.Criteria;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        // Create compound criteria items.
        CompoundCriteriaItem userItem = new();
        CompoundCriteriaItem groupItem = new();

        // Create criteria.
        Criteria criteria = new(
            new Dictionary<string, CompoundCriteriaItem>
            {
                { "user", userItem },
                { "group", groupItem }
            }
        );
    }
}

AddType(string, CriteriaItem)

Adds the specified object type to this criteria, and sets the criteria items for that object type.

Criteria AddType(string objectType, CriteriaItem criteriaItem)

Parameters

  • objectType – Specifies the name of the object type to add. The name must exactly match the name of the corresponding object class in your directory schema e.g. user, group.
  • criteriaItem – Specifies the criteria item to set. If this parameter is set to null, an empty compound criteria item will be set.

Return value

The method returns this instance of Criteria after updating it.

Examples

The following code sample adds two object types and sets the criteria items for them.

PowerShell
$criteria = YOUR-CRITERIA

# Create criteria items.
$userItem = $criteria.CreateCompound()
$groupItem = $criteria.CreateSimple()

# Add object types with their criteria items.
$criteria.AddType("user", $userItem).AddType("group", $groupItem)
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>

        // Create criteria items.
        CompoundCriteriaItem userItem = new();
        SimpleCriteriaItem groupItem = new();

        // Add object types with their criteria items.
        criteria.AddType("user", userItem).AddType("group", groupItem);
    }
}

AddType(string, string)

Adds the specified object type to this criteria, and generates its criteria items from a criteria expression. For details about building criteria expressions, see How to build criteria.

Criteria AddType(string objectType, string criteriaItem)

Parameters

  • objectType – Specifies the name of the object type to add. The name must exactly match the name of the corresponding object class in your directory schema e.g. user, group.
  • criteriaItem – Specifies the criteria expression.

Return value

The method returns this instance of Criteria after updating it.

Examples

The following code sample creates criteria that matches all users from the London office.

PowerShell
$criteria = YOUR-CRITERIA

# Add criteria for the User object type.
$criteria.AddType("user", {physicalDeliveryOfficeName -eq "London"})
C#
// Criteria expressions can be used in PowerShell only.

AddTypes()

Adds a collection of object types to this criteria.

Criteria AddTypes(IEnumerable<string> objectTypes)

Parameters

The objectType parameter specifies a collection of object type names to add. The names must exactly match the names of the corresponding object classes in your directory schema e.g. user, group.

Return value

The method returns this instance of Criteria after updating it.

Examples

The following code sample adds the User and Group object types to the criteria.

PowerShell
$criteria = YOUR-CRITERIA
$criteria.AddTypes(@("user", "group"))
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>
        criteria.AddTypes(new[] { "user", "group" });
    }
}

CreateSimple()

Creates a new SimpleCriteriaItem instance.

SimpleCriteriaItem CreateSimple()

CreateCompound()

Creates a new CompoundCriteriaItem instance.

CompoundCriteriaItem CreateCompound()

CreateAdvanced()

Creates a new AdvancedCriteriaItem instance.

AdvancedCriteriaItem CreateAdvanced()

Clone()

Creates a deep copy of this criteria.

Criteria Clone()

Item[string]

Gets the criteria items that apply to the specified object type.

CompoundCriteriaItem this[string objectType]

Parameters

The objectType parameter specifies the name of an object type which is present in this criteria.

Examples

The following code sample gets the criteria items of the User object type.

PowerShell
$criteria = YOUR-CRITERIA

# Add the User object type.
$criteria.AddType("user")

# Get user criteria.
$userCriteria = $criteria["user"]
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>

        // Add the User object type.
        criteria.AddType("user");

        // Get user criteria.
        CompoundCriteriaItem userCriteria = criteria["user"];
    }
}

The following code sample adds a criteria item to the User object type using the Add method.

PowerShell
$criteria = YOUR-CRITERIA

# Add criteria item for users.
$criteria.AddType("user")
$item = $criteria.CreateSimple()
$criteria["user"].Add($item)
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>

        // Add criteria item for users.
        criteria.AddType("user");
        SimpleCriteriaItem item = new();
        criteria["user"].Add(item);
    }
}

Requirements

Minimum required version: 2023

See also