Sorry, search feature is not supported in Internet Explorer 11

IAdmO365Tenant4

The IAdmO365Tenant4 interface extends the IAdmO365Tenant interface with the ability to get the national cloud and specify the credential that Adaxes will use to authenticate to the Microsoft 365 tenant.

Inheritance: IAdmO365Tenant3

Methods

  • Method

  • Description

  • CreateCredential()

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

  • GetCredential()

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

  • SetCredentials2()

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

Properties

  • Property

  • Description

  • TenantId

  • Gets the identifier of the Microsoft 365 tenant.

  • NationalCloud

  • Gets the national cloud of the Microsoft 365 tenant.

Details

CreateCredential()

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

IAdmO365TenantCredential CreateCredential(ADM_O365TENANT_CREDTYPE_ENUM credentialType)

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 IAdmO365AppSecretTenantCredential or IAdmO365UsernamePwdTenantCredential interface.

IAdmO365TenantCredential GetCredential()

Return value

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


SetCredentials2()

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

void SetCredentials2(IAdmO365TenantCredential newCredential, Boolean 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

Example 1: Set user account credential

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

$tenantName = "My tenant"
$username = "administrator@company.onmicrosoft.com"
$password = "secret"

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

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

# Set credential
$credential = $tenant.CreateCredential("ADM_O365TENANT_CREDTYPE_USERNAMEPWD")
$credential.Username = $username
$credential.SetPassword($password)

$tenant.SetCredentials2($credential, $False)
C#
using System;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;

class Program
{
    static void Main(string[] args)
    {
        const string tenantName = "My tenant";
        const string username = "administrator@company.onmicrosoft.com";
        const string password = "secret";

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

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

        // Set credential
        IAdmO365UsernamePwdTenantCredential credential = (IAdmO365UsernamePwdTenantCredential)
            tenant.CreateCredential(ADM_O365TENANT_CREDTYPE_ENUM.ADM_O365TENANT_CREDTYPE_USERNAMEPWD);
        credential.Username = username;
        credential.SetPassword(password);

        tenant.SetCredentials2(credential, false);
    }
}

Example 2: Set application credential

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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

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

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

$tenant.SetCredentials2($credential, $False)
C#
using System;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;

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 adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

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

        // Set credential
        IAdmO365AppSecretTenantCredential credential = (IAdmO365AppSecretTenantCredential)
            tenant.CreateCredential(ADM_O365TENANT_CREDTYPE_ENUM.ADM_O365TENANT_CREDTYPE_APPSECRET);
        credential.AppId = applicationId;
        credential.TenantId = tenantId;
        credential.SetSecret(clientSecret);

        tenant.SetCredentials2(credential, false);
    }
}

TenantId

Gets the identifier of the Microsoft 365 tenant.

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

NationalCloud

Gets the national cloud of the Microsoft 365 tenant.


Requirements

Minimum required version: 2021.1

See also