Skip to content

IAdmO365ServiceStateRequirement

The IAdmO365ServiceStateRequirement 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.

Inheritance: The IAdmO365ServiceStateRequirement interface inherits from the IUnknown interface.

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:
  • Boolean
  • 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:
  • Boolean
  • 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:
  • Boolean
  • 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.

# 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_O365ACCOUNT_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)
// 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");
IAdmO365LicenseCondition microsoft365LicenseCondition =
    (IAdmO365LicenseCondition)condition.GetCondition();
microsoft365LicenseCondition.ConditionType =
    ADM_O365ACCOUNT_CONDITION_TYPE_ENUM.ADM_O365ACCOUNT_CONDITION_TYPE_SERVICESPECIFIC;
IAdmO365ServiceStateRequirement[] serviceRequirements =
    microsoft365LicenseCondition.ServiceRequirements;
foreach (IAdmO365ServiceStateRequirement 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: 2014.1

See also