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
-
Constructor
-
Description
-
Criteria()
-
Initializes a new instance of the Criteria class.
-
Criteria(Dictionary<string, CompoundCriteriaItem>)
-
Initializes a new instance of the Criteria class with the specified object types and criteria items.
Methods
-
Method
-
Description
-
AddType(string, CriteriaItem)
-
Adds the specified object type to this criteria, and sets the criteria items for that object type.
-
AddType(string, string)
-
Adds the specified object type to this criteria and creates its criteria items from a criteria expression.
-
AddTypes()
-
Adds a collection of object types to this criteria.
-
CreateSimple()
-
Creates a simple criteria item.
-
CreateCompound()
-
Creates a compound criteria item.
-
CreateAdvanced()
-
Creates an advanced criteria item.
-
Clone()
-
Creates a deep copy of this criteria.
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
- objectTypes – 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 System.Collections.Generic;
using Softerra.Adaxes.Directory.Criteria;
class Program
{
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 }
}
);
}
}
Remarks
To create criteria in PowerShell, use New-AdmCriteria.
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 – 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 – 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 { 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 – 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 – 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.
$criteria = YOUR-CRITERIA
# Add criteria for the User object type.
$criteria.AddType("user", {physicalDeliveryOfficeName -eq "London"})
Remarks
Criteria expressions can only be used in PowerShell.
AddTypes()
Adds a collection of object types to this criteria.
Criteria AddTypes(IEnumerable<string> objectTypes)
Parameters
- objectType – 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 { 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
- objectType – 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 { 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 { 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