IAdmM365Container

The IAdmM365Container interface represents the container where Microsoft 365 tenants are stored. The container is located at the Adaxes Configuration Server (AD LDS).

Inheritance: IAdmTop

To get an instance of the IAdmM365Container interface, you need to bind to the Microsoft 365 container using the "CloudServicesO365" alias.

Methods

Details

HasTenants()

Checks whether there are any Microsoft 365 tenants registered in Adaxes.

bool HasTenants()

HasTenantsWithExchange()

Checks whether there is at least one registered Microsoft 365 tenant that provides access to Exchange Online.

bool HasTenantsWithExchange()

EnsureCanRegisterTenant()

Checks whether the current user has sufficient permissions to register a Microsoft 365 tenant. If the user has insufficient permissions, the method throws a COMException with the UNWILLING_TO_PERFORM error code.

void EnsureCanRegisterTenant()

RegisterTenant()

Registers a Microsoft 365 tenant in Adaxes.

IAdmM365Tenant RegisterTenant(IAdmM365TenantRegistrationParams registrationParams, bool checkOnly)

Parameters

  • registrationParams - Specifies parameters for the Microsoft 365 tenant registration. To create the parameters, use method CreateRegistrationParams.
  • checkOnly - If set to true, the method only checks whether the Microsoft 365 tenant can be registered using the specified parameters.

Examples

The following code sample registers a Microsoft 365 tenant with application credential.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$applicationId = "e97b76b5-1e24-4d96-b251-1f938cb6459f"
$tenantId = "a5885e21-2ba8-4195-9a88-3756d1fe9023"
$clientSecret = "fK7--~yjs1fH8U9m5heb_VQyHBOybZlEOc"

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the 'Microsoft 365' container
$containerPath = $service.Backend.GetConfigurationContainerPath("CloudServicesO365")
$container = $service.OpenObject($containerPath.ToString(),$null, $null, 0)

# Register tenant
$credential = $container.CreateCredential("ADM_M365TENANT_CREDTYPE_APPSECRET")
$credential.AppId = $applicationId
$credential.TenantId = $tenantId
$credential.SetSecret($clientSecret)

$parameters = $container.CreateRegistrationParams()
$parameters.Credential = $credential

$container.RegisterTenant($parameters, $False)
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string applicationId = "76bc664d-b6d1-41b6-b589-409416161c32";
        const string tenantId = "a5765e21-2ba8-4195-9a88-3756d1fe9453";
        const string clientSecret = "WIz6SBuc7-~1g6A-HJ7q~A8g04G66Q_5ep";

        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the 'Microsoft 365' container
        string configurationContainerPath = service.Backend.GetConfigurationContainerPath(
            "CloudServicesO365");
        IAdmM365Container container = (IAdmM365Container)service.OpenObject(
            configurationContainerPath, null, null, 0);

        // Register tenant
        IAdmM365AppSecretTenantCredential credential = 
            (IAdmM365AppSecretTenantCredential)container.CreateCredential(
                ADM_M365TENANT_CREDTYPE_ENUM.ADM_M365TENANT_CREDTYPE_APPSECRET);
        credential.AppId = applicationId;
        credential.TenantId = tenantId;
        credential.SetSecret(clientSecret);

        IAdmM365TenantRegistrationParams parameters = container.CreateRegistrationParams();
       parameters.Credential = credential;

        container.RegisterTenant(parameters, false);
    }
}

CreateRegistrationParams()

Returns the IAdmM365TenantRegistrationParams interface used to specify parameters for registering a Microsoft 365 tenant.

IAdmM365TenantRegistrationParams CreateRegistrationParams()

CreateCredential()

Creates an object that represents Microsoft 365 tenant credential of the specified type. Depending on the type, the object will support either the IAdmM365AppSecretTenantCredential or IAdmM365UsernamePwdTenantCredential interface.

IAdmM365TenantCredential CreateCredential(ADM_M365TENANT_CREDTYPE_ENUM credentialType)

GetRegisteredSkus()

Gets a list of Microsoft 365 license plans available in all Microsoft 365 tenants registered in Adaxes.

IAdmM365SkuInfo[] GetRegisteredSkus(bool enabledOnly)

Parameters

The enabledOnly parameter specifies whether to return only Microsoft 365 license plans enabled in Adaxes. A license plan is considered enabled if it is enabled at least in one tenant.

Examples

The following code sample outputs all enabled Microsoft 365 plans available in the registered Microsoft 365 tenants.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$enabledOnly = $true

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the 'Microsoft 365' container
$configurationContainerPath = $service.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $service.OpenObject($configurationContainerPath, $null, $null, 0)

# Get enabled Microsoft 365 plans
$skuInfos = $configurationContainer.

foreach ($skuInfo in $skuInfos)
{
    Write-Host "`tDisplay name:" $skuInfo.DisplayName
    Write-Host "`tSKU ID:" $skuInfo.SkuId
    Write-Host "`tSKU Part Number:" $skuInfo.SkuPartNumber
    Write-Host
}
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const bool enabledOnly = true;

        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the 'Microsoft 365' container
        string configurationContainerPath = service.Backend.GetConfigurationContainerPath(
            "CloudServicesO365");
        IAdmM365Container configurationContainer = (IAdmM365Container)service.OpenObject(
            configurationContainerPath, null, null, 0);

        // Get enabled Microsoft 365 plans
        IAdmM365SkuInfo[] skuInfos = configurationContainer.;

        foreach (IAdmM365SkuInfo skuInfo in skuInfos)
        {
            Console.WriteLine("\tDisplay name: " + skuInfo.DisplayName);
            Console.WriteLine("\tSKU ID: " + skuInfo.SkuId);
            Console.WriteLine("\tSKU Part Number: " + skuInfo.SkuPartNumber);
            Console.WriteLine();
        }
    }
}

GetRegisteredServices()

Gets Microsoft 365 services provided by Microsoft 365 license plans in all registered tenants.

IAdmM365Service[] GetRegisteredServices(bool enabledOnly)

Parameters

The enabledOnly parameter specifies whether to return only Microsoft 365 services enabled in Adaxes. A service is considered enabled if it is enabled at least in one tenant.

Examples

The following code sample outputs all Microsoft 365 services available in the registered Microsoft 365 tenants.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
                    
$enabledOnly = $False
                    
# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the 'Microsoft 365' container
$configurationContainerPath = $service.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $service.OpenObject($configurationContainerPath, $null, $null, 0)

# Output all Microsoft 365 services
$microsoft365Services = $configurationContainer.

foreach ($microsoft365Service in $microsoft365Services)
{
    Write-Host "`tService name:" $microsoft365Service.ServiceName
    Write-Host "`tService display name:" $microsoft365Service.ServiceDisplayName
    Write-Host "`tEnabled:" $microsoft365Service.Enabled
    Write-Host
}
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const bool enabledOnly = false;
            
        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the 'Microsoft 365' container
        string configurationContainerPath = service.Backend.GetConfigurationContainerPath(
            "CloudServicesO365");
        IAdmM365Container configurationContainer = (IAdmM365Container)service.OpenObject(
            configurationContainerPath, null, null, 0);

        // Output all Microsoft 365 services
        IAdmM365Service[] microsoft365Services = configurationContainer.;

        foreach (IAdmM365Service microsoft365Service in microsoft365Services)
        {
            Console.WriteLine("\tService name: " + microsoft365Service.ServiceName);
            Console.WriteLine("\tService display name: " + microsoft365Service.ServiceDisplayName);
            Console.WriteLine("\tEnabled: " + microsoft365Service.Enabled);
            Console.WriteLine();
        }
    }
}

GetAllRegisteredLicenses()

Returns all the Microsoft 365 licenses available in all the Microsoft 365 tenants registered in Adaxes.

IAdmM365License[] GetAllRegisteredLicenses(bool enabledOnly)

Parameters

The enabledOnly parameter specifies whether to return only enabled Microsoft 365 licenses. A license is considered enabled if it is enabled in at least one Microsoft 365 tenant.


Requirements

Minimum required version: 2023

See also