IAdmO365LicenseCondition2
The IAdmO365LicenseCondition2 interface extends the IAdmO365LicenseCondition interface with the ability to check assignment of specific Microsoft 365 licenses.
Inheritance: IAdmO365LicenseCondition
Properties
-
Property
-
Description
-
LicenseRequirements
-
Gets or sets requirements to the state of Microsoft 365 licenses that should be satisfied to meet the condition.
Details
LicenseRequirements
Gets or sets requirements to the state of Microsoft 365 licenses that should be satisfied to meet the condition.
- Type:
- IAdmO365LicenseStateRequirement[]
- Access:
- Read/Write
Remarks
The property is taken into account only if the IAdmO365LicenseCondition::ConditionType property is set to ADM_O365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC.
Examples
The following code sample creates an action set that cancels an operation if Microsoft 365 license ENTERPRISEPACK is assigned.
- Powershell
-
# The $obj variable refers to a business rule, custom command or scheduled task. # Create a new action set. $actionsAndConditions = $obj.ConditionedActions.Create() $actionsAndConditions.ConditionsLogicalOperation = "ADM_LOGICALOPERATION_AND" $actionsAndConditions.SetInfo() #----------------------------------------------------------------------- # If ENTERPRISEPACK license is assigned $condition = $actionsAndConditions.Conditions.CreateEx("adm-O365LicenseCondition") $licenseCondition = $condition.GetCondition() $licenseCondition.ConditionType = "ADM_O365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC" $licenseRequirements = $licenseCondition.LicenseRequirements foreach ($requirement in $licenseRequirements) { $license = $requirement.License if ($license.Sku.SkuPartNumber -eq "ENTERPRISEPACK") { $requirement.Enabled = $True $requirement.LicenseState = $True break } } $licenseCondition.LicenseRequirements = $licenseRequirements $condition.SetCondition($licenseCondition) $condition.SetInfo() $actionsAndConditions.Conditions.Add($condition) #----------------------------------------------------------------------- # Cancel the operation $action = $actionsAndConditions.Actions.CreateEx("adm-CancelOperationAction") $action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC" $cancelAction = $action.GetAction() $cancelAction.ReasonMessage = "My Reason" $action.SetAction($cancelAction) $action.SetInfo() $actionsAndConditions.Actions.Add($action) # Add the set to the business rule, custom command or scheduled task. $obj.ConditionedActions.Add($actionsAndConditions)
- C#
-
// The obj variable refers to a business rule, custom command or scheduled task. // Create a new action set. IAdmBusinessRuleConditionedActions actionsAndConditions = (IAdmBusinessRuleConditionedActions)obj.ConditionedActions.Create(); actionsAndConditions.ConditionsLogicalOperation = ADM_LOGICALOPERATION_ENUM.ADM_LOGICALOPERATION_AND; actionsAndConditions.SetInfo(); //////////////////////////////////////////////////////////////////////// // If ENTERPRISEPACK license is assigned IAdmBusinessRuleCondition condition = (IAdmBusinessRuleCondition)actionsAndConditions.Conditions.CreateEx( "adm-O365LicenseCondition"); IAdmO365LicenseCondition2 licenseCondition = (IAdmO365LicenseCondition2)condition.GetCondition(); licenseCondition.ConditionType = ADM_O365ACCOUNT_CONDITION_TYPE_ENUM.ADM_O365ACCOUNT_CONDITION_TYPE_LICENSESPECIFIC; IAdmO365LicenseStateRequirement[] licenseRequirements = licenseCondition.LicenseRequirements; foreach (IAdmO365LicenseStateRequirement requirement in licenseRequirements) { IAdmO365License license = (IAdmO365License) requirement.License; if (license.Sku.SkuPartNumbe == "ENTERPRISEPACK") { requirement.Enabled = true; requirement.LicenseState = true; } } licenseCondition.LicenseRequirements = licenseRequirements; condition.SetCondition(licenseCondition); condition.SetInfo(); actionsAndConditions.Conditions.Add(condition); //////////////////////////////////////////////////////////////////////// // Cancel the operation IAdmBusinessRuleAction action = (IAdmBusinessRuleAction)actionsAndConditions.Actions.CreateEx( "adm-CancelOperationAction"); action.ExecutionOptions = ADM_ACTIONEXECUTIONOPTIONS_ENUM.ADM_ACTIONEXECUTIONOPTIONS_SYNC; IAdmCancelOperationAction cancelAction = (IAdmCancelOperationAction)action.GetAction(); cancelAction.ReasonMessage = "My Reason"; action.SetAction(cancelAction); action.SetInfo(); actionsAndConditions.Actions.Add(action); // Add the set to the business rule, custom command or scheduled task. obj.ConditionedActions.Add(actionsAndConditions);
Requirements
Minimum required version: 2021.1