IAdmM365Tenant

The IAdmM365Tenant interface represents a Microsoft 365 tenant in Adaxes.

Inheritance: IAdmTop

Methods

  • Method

  • Description

  • FindAssociatedObjects()

  • Returns an instance of the IAdmDirectorySearcher interface that can be used to find all directory objects associated with the Microsoft 365 tenant.

  • ReloadData()

  • Reloads the cache of information related to the Microsoft 365 tenant.

  • SetCredentials()

  • Sets the credential that Adaxes will use to authenticate to the Microsoft 365 tenant.

  • GetCredential()

  • Returns an object that represents the credential that Adaxes uses to authenticate to the Microsoft 365 tenant.

  • CreateCredential()

  • Creates an object that represents Microsoft 365 tenant credential of the specified type.

Properties

  • Property

  • Description

  • TenantId

  • Gets the identifier of the Microsoft 365 tenant.

  • NationalCloud

  • Gets the national cloud of the Microsoft 365 tenant.

  • AssociatedScopeItems

  • Gets a collection of activity scope items that comprise the tenant scope.

  • CompanyInfo

  • Gets the IAdmM365TenantCompanyInfo interface that contains information about the company that owns the Microsoft 365 tenant.

  • Priority

  • Gets or sets a value that specifies the priority of the Microsoft 365 tenant.

  • SynchronizePasswords

  • Gets or sets a value that indicates whether user passwords in Microsoft 365 should be automatically set or updated once a new user is created or a password is changed with the help of Adaxes.

  • DisplayTemporaryPasswords

  • Gets or sets a value that indicates whether temporary passwords generated by Microsoft 365 for new Microsoft 365 users will be displayed in the Adaxes Execution Log.

  • EmailTemporaryPasswords

  • Gets or sets a value that indicates whether temporary passwords generated automatically by Microsoft 365 for new Microsoft 365 users will be sent to the emails specified in the TemporaryPasswordsRecipients property.

  • TemporaryPasswordsRecipients

  • Gets or sets a semicolon separated list of email addresses to which temporary passwords will be sent if the EmailTemporaryPasswords property is set to true.

  • Skus

  • Gets an array of Microsoft 365 plans available in the tenant.

  • TenantName

  • Gets or sets the name of the tenant.

  • UserName

  • Gets the ID of the Microsoft 365 account used by Adaxes to perform operations within the tenant.

  • EnableRemoteMailboxes

  • Gets or sets a value that indicates whether to create remote mailboxes for users associated with the tenant.

  • RemoteMailboxesRemoteRoutingAddress

  • Gets or sets a template for a remote routing address, assigned when enabling a remote mailbox.

  • DisableRemoteMailboxes

  • Gets or sets a value that indicates whether to delete remote mailboxes of users associated with the tenant.

  • SourceAnchor

  • Gets or sets the LDAP name of the property used as the source anchor for the Microsoft 365 tenant.

  • PreCreateSyncedObjectEnabled

  • Gets or sets a value indicating whether Microsoft Entra objects should be automatically created and deleted after creating and deleting Active Directory objects.

Details

FindAssociatedObjects()

Returns an instance of the IAdmDirectorySearcher interface that can be used to find all directory objects associated with the Microsoft 365 tenant.

object FindAssociatedObjects()

Examples

The following code sample outputs directory objects associated with a Microsoft 365 tenant.

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

$tenantName = "My Company"

# 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)

# Bind to the tenant
$tenant = $configurationContainer.GetObject("adm-O365Tenant", "CN=$tenantName")

# Retrieve an interface to search for associated objects
$associatedObjectsSeacher = $tenant.FindAssociatedObjects()

# Set search parameters
$associatedObjectsSeacher.PageSize = 500

try
{
    # Execute search
    $searchResultIterator = $associatedObjectsSeacher.ExecuteSearch()
    $searchResults = $searchResultIterator.FetchAll()
    
    foreach ($searchResult in $searchResults)
    {
        Write-Host "`t" $searchResult.Name 
    }
}
finally
{
    # Release resources used by the search
    $searchResultIterator.Dispose()
}

C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Adsi.Search;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.Microsoft365;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string tenantName = "My Company";

        // 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");
        IADsContainer configurationContainer = (IADsContainer)service.OpenObject(
            configurationContainerPath, null, null, 0);

        // Bind to the tenant
        IAdmM365Tenant tenant = (IAdmM365Tenant)configurationContainer.GetObject(
            "adm-O365Tenant", "CN=" + tenantName);

        // Retrieve an interface to search for associated objects
        IAdmDirectorySearcher associatedObjectsSeacher =
            (IAdmDirectorySearcher)tenant.FindAssociatedObjects();

        // Set search parameters
        associatedObjectsSeacher.PageSize = 500;

        // Execute search
        using (IAdmSearchResultIterator searchResultIterator =
            associatedObjectsSeacher.ExecuteSearch())
        {
            AdmSearchResult[] searchResults = searchResultIterator.FetchAll();

            foreach (AdmSearchResult searchResult in searchResults)
            {
                Console.WriteLine("\t" + searchResult.Name);
            }
        }
    }
}

ReloadData()

Reloads the cache of information related to the Microsoft 365 tenant. The cache includes the Microsoft 365 plans available in the tenant, domains registered for the tenant, and also company information, such as company name, city, etc.

void ReloadData()

SetCredentials()

Sets the credential that Adaxes will use to authenticate to the Microsoft 365 tenant.

void SetCredentials(IAdmM365TenantCredential newCredential, bool checkOnly)

Parameters

  • newCredential – Specifies the credential to be set.
  • checkOnly – If set to true, the method only checks whether the specified credential can be set for the Microsoft 365 tenant.

Examples

The following code sample sets application credential for the Microsoft 365 tenant.

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

$tenantName = "My tenant"
$applicationId = "e97b76b5-1e24-4d96-b251-1f938cb9549f"
$tenantId = "a5885e21-2ba8-4195-9a88-3756d1fe9323"
$clientSecret = "fK7--~yjs1fH8U9m5heb_VQyHNAybZlEOc"

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

# Bind to the Microsoft 365 tenant
$configurationContainerPath = $service.Backend.GetConfigurationContainerPath("CloudServicesO365")
$configurationContainer = $service.OpenObject($configurationContainerPath, $null, $null, 0)
$tenant = $configurationContainer.GetObject("adm-O365Tenant", "CN=$tenantName")

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

$tenant.SetCredentials($credential, $false)
C#
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi.Microsoft365;

class Program
{
    static void Main(string[] args)
    {
        const string tenantName = "My tenant";
        const string applicationId = "e97b76b5-1e24-4d96-b251-1f938cb9549f";
        const string tenantId = "a5885e21-2ba8-4195-9a88-3756d1fe9323";
        const string clientSecret = "fK7--~yjs1fH8U9m5heb_VQyHNAybZlEOc";

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

        // Bind to the Microsoft 365 tenant
        string configurationContainerPath = service.Backend.GetConfigurationContainerPath(
            "CloudServicesO365");
        IADsContainer configurationContainer = (IADsContainer)service.OpenObject(
            configurationContainerPath, null, null, 0);
        IAdmM365Tenant tenant = (IAdmM365Tenant)configurationContainer.GetObject(
            "adm-O365Tenant", "CN=" + tenantName);

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

        tenant.SetCredentials(credential, false);
    }
}

GetCredential()

Returns an object that represents the credential that Adaxes uses to authenticate to the Microsoft 365 tenant. Depending on the type of credentials specified for the tenant, the object will support the IAdmM365AppSecretTenantCredential or IAdmM365UsernamePwdTenantCredential interface.

IAdmM365TenantCredential GetCredential()

Return value

The return value never contains the account password or the client application secret.


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)

TenantId

Gets the identifier of the Microsoft 365 tenant.

  • Type:
  • Guid
  • Access:
  • Read-only

NationalCloud

Gets the national cloud of the Microsoft 365 tenant.


AssociatedScopeItems

Gets a collection of activity scope items that comprise the tenant scope. Each item in the collection supports the IAdmActivityScopeItem interface.


CompanyInfo

Gets the IAdmM365TenantCompanyInfo interface that contains information about the company that owns the Microsoft 365 tenant.


Priority

Gets or sets a value that specifies the priority of the Microsoft 365 tenant. The value is used to identify which tenant to use when more than one tenant is associated with a user.

  • Type:
  • int
  • Access:
  • Read/Write

SynchronizePasswords

Gets or sets a value that indicates whether user passwords in Microsoft 365 should be automatically set or updated once a new user is created or a password is changed with the help of Adaxes.

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

DisplayTemporaryPasswords

Gets or sets a value that indicates whether temporary passwords generated by Microsoft 365 for new Microsoft 365 users will be displayed in the Adaxes Execution Log.

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

EmailTemporaryPasswords

Gets or sets a value that indicates whether temporary passwords generated automatically by Microsoft 365 for new Microsoft 365 users will be sent to the emails specified in the TemporaryPasswordsRecipients property.

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

TemporaryPasswordsRecipients

Gets or sets a semicolon separated list of email addresses to which temporary passwords will be sent if the EmailTemporaryPasswords property is set to true. You can use value references (e.g. %mail%) to specify the addresses. Value references will be replaced with corresponding property values of the user whose Microsoft 365 account is activated.

  • Type:
  • string
  • Access:
  • Read/Write

Skus

Gets an array of Microsoft 365 plans available in the tenant.


TenantName

Gets or sets the name of the tenant.

  • Type:
  • string
  • Access:
  • Read/Write

UserName

Gets the ID of the Microsoft 365 account used by Adaxes to perform operations within the tenant.

  • Type:
  • string
  • Access:
  • Read-only

EnableRemoteMailboxes

Gets or sets a value that indicates whether to create remote mailboxes for users associated with the tenant. Such mailboxes will be created when a license that contains an Exchange Online service is assigned.

  • Type:
  • Object
  • Access:
  • Read/Write

Possible values

  • null (default value) – Remote mailboxes will be enabled if the Exchange Organization operates in hybrid mode.
  • false – Remote mailboxes will never be enabled.
  • true – Remote mailboxes will be enabled even if the Exchange Organization is not a part of a hybrid deployment.

RemoteMailboxesRemoteRoutingAddress

Gets or sets a template for a remote routing address, assigned when enabling a remote mailbox. If the template is null or an empty string, a remote routing address will be generated automatically. You can use value references in the template (e.g. %firstname%.%lastname%@mycompany.mail.onmicrosoft.com*).

  • Type:
  • string
  • Access:
  • Read/Write

DisableRemoteMailboxes

Gets or sets a value that indicates whether to delete remote mailboxes of users associated with the tenant. Such mailboxes will be deleted when a license that contains an Exchange Online service is revoked.

  • Type:
  • Object
  • Access:
  • Read/Write

Possible values

  • null (default value) – Remote mailboxes will be disabled if the Exchange Organization operates in hybrid mode.
  • false – Remote mailboxes will never be disabled.
  • true – Remote mailboxes will be disabled even if the Exchange Organization is not a part of a hybrid deployment.

SourceAnchor

Gets or sets the LDAP name of the property used as the source anchor for the Microsoft 365 tenant.

  • Type:
  • string
  • Access:
  • Read/Write

PreCreateSyncedObjectEnabled

Gets or sets a value indicating whether Microsoft Entra objects should be automatically created and deleted after creating and deleting Active Directory objects.

  • Type:
  • Object
  • Access:
  • Read/Write

Possible values

  • null (default behavior) – Microsoft Entra objects will be created and deleted only if Microsoft Entra Connect is enabled for the Microsoft Entra domain.
  • true – Microsoft Entra objects will be created and deleted even if Microsoft Entra Connect is disabled.
  • false – objects will never be created and deleted by Adaxes.

Remarks

If a Microsoft Entra object was not created by Adaxes, it will never be automatically deleted when the synchronized Active Directory object is deleted.


Requirements

Minimum required version: 2023

See also