IAdmM365ServiceStateRequirement

The IAdmM365ServiceStateRequirement interface represents requirements to the state of a Microsoft 365 service that should be satisfied to meet the If is licensed for Microsoft 365 condition.

Properties

  • Property

  • Description

  • Enabled

  • Gets or sets a value that indicates whether to check the state of the service for a user.

  • ServiceState

  • Gets or sets the service state required to meet the condition.

  • CanBeChecked

  • Gets or sets a value that indicates whether the service is available at least in one license plan.

  • Service

  • Gets or sets a Microsoft 365 service that must be enabled or disabled to meet the condition.

Details

Enabled

Gets or sets a value that indicates whether to check the state of the service for a user. If false, the service state is ignored.

  • Type:
  • bool
  • Access:
  • Read/Write

ServiceState

Gets or sets the service state required to meet the condition. If true, the service must be enabled for a user. If false, the service must be disabled.

  • Type:
  • bool
  • Access:
  • Read/Write

CanBeChecked

Gets or sets a value that indicates whether the service is available at least in one license plan. If false, there is no such service in the license plans available in Microsoft 365 tenants registered in Adaxes.

  • Type:
  • bool
  • Access:
  • Read/Write

Service

Gets or sets a Microsoft 365 service that must be enabled or disabled to meet the condition.

Examples

The following code sample creates a set of actions and conditions that updates a user if the Exchange Online (Plan 2) service is enabled.

PowerShell
# The $obj variable refers to a business rule, custom command or scheduled task

# Create a new set of actions and conditions
$actionsAndConditions = $obj.ConditionedActions.Create()
$actionsAndConditions.ConditionsLogicalOperation = `
    "ADM_LOGICALOPERATION_AND"
$actionsAndConditions.SetInfo()

#-----------------------------------------------------------------------
# If Exchange Online (Plan 2) is enabled for the user
$condition = $actionsAndConditions.Conditions.CreateEx(
    "adm-O365LicenseCondition")
$microsoft365LicenseCondition = $condition.GetCondition()
$microsoft365LicenseCondition.ConditionType = "ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC"
$serviceRequirements = $microsoft365LicenseCondition.ServiceRequirements
foreach ($requirement in $serviceRequirements)
{
    if ($requirement.Service.ServiceName -eq "EXCHANGE_S_ENTERPRISE")
    {
        $requirement.Enabled = $true
        $requirement.ServiceState = $true
        break
    }
}
$microsoft365LicenseCondition.ServiceRequirements = $serviceRequirements
$condition.SetCondition($microsoft365LicenseCondition)
$condition.SetInfo()
$actionsAndConditions.Conditions.Add($condition)

#-----------------------------------------------------------------------
# Update Description
$action = $actionsAndConditions.Actions.CreateEx(
    "adm-SetPropertiesAction")
$action.ExecutionOptions = "ADM_ACTIONEXECUTIONOPTIONS_SYNC"
$updateAction = $action.GetAction()
$descriptionValue = New-Object "Softerra.Adaxes.Adsi.AdsPropertyValue"
$descriptionValue.PutObjectProperty("ADSTYPE_UNKNOWN", "Mailbox in cloud")
$propertyEntry = New-Object "Softerra.Adaxes.Adsi.AdsPropertyEntry"
$propertyEntry.Name = "description" # Description
$propertyEntry.ADsType = "ADSTYPE_CASE_IGNORE_STRING"
$propertyEntry.ControlCode = "ADS_PROPERTY_UPDATE"
$propertyEntry.Values =
    @([Softerra.Adaxes.Interop.Adsi.Cache.IADsPropertyValue]$descriptionValue)
$updateAction.PropertyList.PutPropertyItem($propertyEntry)

$action.SetAction($updateAction)
$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 set of actions and conditions
IAdmBusinessRuleConditionedActions actionsAndConditions =
    (IAdmBusinessRuleConditionedActions)obj.ConditionedActions.Create();
actionsAndConditions.ConditionsLogicalOperation =
    ADM_LOGICALOPERATION_ENUM.ADM_LOGICALOPERATION_AND;
actionsAndConditions.SetInfo();

////////////////////////////////////////////////////////////////////////
// If Exchange Online (Plan 2) is disabled for the user
IAdmBusinessRuleCondition condition =
    (IAdmBusinessRuleCondition)actionsAndConditions.Conditions.CreateEx(
        "adm-O365LicenseCondition");
IAdmM365LicenseCondition microsoft365LicenseCondition =
    (IAdmM365LicenseCondition)condition.GetCondition();
microsoft365LicenseCondition.ConditionType =
    ADM_M365ACCOUNT_CONDITION_TYPE_ENUM.ADM_M365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC;
IAdmM365ServiceStateRequirement[] serviceRequirements =
    microsoft365LicenseCondition.ServiceRequirements;
foreach (IAdmM365ServiceStateRequirement requirement in serviceRequirements)
{
    if (requirement.Service.ServiceName == "EXCHANGE_S_ENTERPRISE")
    {
        requirement.Enabled = true;
        requirement.ServiceState = true;
        break;
    }
}
microsoft365LicenseCondition.ServiceRequirements = serviceRequirements;
condition.SetCondition(microsoft365LicenseCondition);
condition.SetInfo();
actionsAndConditions.Conditions.Add(condition);

////////////////////////////////////////////////////////////////////////
// Update Description
IAdmBusinessRuleAction action =
    (IAdmBusinessRuleAction)actionsAndConditions.Actions.CreateEx(
        "adm-SetPropertiesAction");
action.ExecutionOptions =
    ADM_ACTIONEXECUTIONOPTIONS_ENUM.ADM_ACTIONEXECUTIONOPTIONS_SYNC;
IAdmSetPropertiesAction updateAction =
    (IAdmSetPropertiesAction)action.GetAction();
AdsPropertyValue descriptionValue = new AdsPropertyValue();
descriptionValue.PutObjectProperty(ADSTYPEENUM.ADSTYPE_UNKNOWN, "Mailbox in cloud");
AdsPropertyEntry propertyEntry = new AdsPropertyEntry();
propertyEntry.Name = "description"; // Description
propertyEntry.ADsType = ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propertyEntry.ControlCode = ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_UPDATE;
propertyEntry.Values = new object[] { descriptionValue };
updateAction.PropertyList.PutPropertyItem(propertyEntry);

action.SetAction(updateAction);
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: 2023

See also