SimpleCriteriaItem

The SimpleCriteriaItem class represents a simple criteria item used in Criteria. A simple criteria item is, effectively, a condition a directory object must meet to match the criteria.

Inheritance: CriteriaItem

Implements: IAdmSimpleCriteriaItem

Namespace: Softerra.Adaxes.Directory.Criteria

Methods

Properties

  • Property

  • Description

  • Values

  • Gets the collection of values that will be compared with the specified property.

Details

SetProperty()

Sets the directory object property to compare with the specified value(s).

SimpleCriteriaItem SetProperty(string propertyName)

Parameters

The propertyName parameter specifies the name of a directory object property. The property name must be specified exactly as it is defined in your directory schema e.g. physicalDeliveryOfficeName, accountExpires.

Return value

The method returns this instance of SimpleCriteriaItem after updating it.

Remarks

Adaxes provides multiple virtual properties to simplify creating certain criteria. For example, the mailEnabled virtual property allows you to filter users who are/aren't mail-enabled. For more details, see the Virtual properties article.

Examples

The following code sample creates a simple criteria item that matches objects with empty description.

PowerShell
$criteria = YOUR-CRITERIA

# Create a simple criteria item.
$simpleItem = $criteria.CreateSimple()
$simpleItem.SetProperty("description").
    SetComparisonOperator("empty").
    AddValue($true)
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        SimpleCriteriaItem item = new();
        item.SetProperty("description").
            SetComparisonOperator("empty").
            AddValue(true);
    }
}

AddValue()

Adds a value to compare with the specified property.

SimpleCriteriaItem AddValue(object value)

Parameters

The value parameter specifies a value to add for comparison with the specified property.

Return value

The method returns this instance of SimpleCriteriaItem after updating it.


AddValues()

Adds a collection of values to compare with the specified property. Multiple values will be evaluated using the specified logical operator.

SimpleCriteriaItem AddValues(ICollection<object> values)

Parameters

The values parameter specifies a collection of values to add for comparison with the specified property.

Return value

The method returns this instance of SimpleCriteriaItem after updating it.

Examples

The following code sample creates Criteria that matches all users from Contoso or Acme companies.

PowerShell
$criteria = YOUR-CRITERIA

# Create a simple criteria item.
$simpleItem = $criteria.CreateSimple()
$simpleItem.SetProperty("company").
    SetComparisonOperator("eq").
    AddValues(@("Contoso", "Acme")).
    SetValueLogicalOperator("OR")
C#
using Softerra.Adaxes.Directory.Criteria;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        SimpleCriteriaItem item = new();
        item.SetProperty("company").
            SetComparisonOperator("eq").
            AddValues(new List<string>(){"Contoso", "Acme"}).
            SetValueLogicalOperator(LogicalOperator.Or);
    }
}

SetComparisonOperator()

Sets the comparison operator for comparing the specified property and specified value(s). For a list of available comparison operators, see the Comparison operators section in the How to build criteria article.

SimpleCriteriaItem SetComparisonOperator(string comparisonOperator)

Return value

The method returns this instance of SimpleCriteriaItem after updating it.

Examples

The following code sample creates a simple criteria item matching objects that were created more than 30 days ago.

PowerShell
$criteria = YOUR-CRITERIA

# Create a simple criteria item.
$simpleItem = $criteria.CreateSimple()
$simpleItem.SetProperty("whenCreated").
    SetComparisonOperator("occurredMoreThan").
    AddValue(30)
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        SimpleCriteriaItem item = new();
        item.SetProperty("whenCreated").
            SetComparisonOperator("occurredMoreThan").
            AddValue(30);
    }
}

SetValueLogicalOperator()

Sets the logical operator for evaluating multiple values. The default logical operator is OR.

SimpleCriteriaItem SetValueLogicalOperator(LogicalOperator logicalOperator)

Return value

The method returns this instance of SimpleCriteriaItem after updating it.

Examples

The following code sample creates a simple criteria item matching all objects whose description contains the words deprovisioned and admin.

PowerShell
$criteria = YOUR-CRITERIA

# Create a simple criteria item.
$simpleItem = $criteria.CreateSimple()
$simpleItem.SetProperty("description").
    SetComparisonOperator("contains").
    AddValues(@("deprovisioned","admin")).
    SetValueLogicalOperator("AND")
C#
using Softerra.Adaxes.Directory.Criteria;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        SimpleCriteriaItem item = new();
        item.SetProperty("description").
            SetComparisonOperator("contains").
            AddValues(new List<string>(){"deprovisioned", "admin"}).
            SetValueLogicalOperator(LogicalOperator.And);
    }
}

Values

Gets the collection of values that will be compared with the specified property.

  • Type:
  • IList<object>
  • Access:
  • Read-only

Requirements

Minimum required version: 2023

See also