IAdmManagedDomainContainer

The IAdmManagedDomainContainer interface provides helper methods for registering managed domains in Adaxes.

Inheritance: IAdmTop

To access this interface, you need to bind to the well-known Managed Domains container where managed domains are stored.

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

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

# Bind to the 'Managed Domains' container.
$managedDomainsPath = $service.Backend.GetConfigurationContainerPath("ManagedDomains")
$managedDomainContainer = $service.OpenObject($managedDomainsPath, $null, $null, 0)
C#
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

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

        // Bind to the 'Managed Domains' container.
        string managedDomainsPath = 
            service.Backend.GetConfigurationContainerPath("ManagedDomains");
        IAdmManagedDomainContainer managedDomainContainer = 
            (IAdmManagedDomainContainer)service.OpenObject(
            managedDomainsPath, null, null, 0);
    }
}

Methods

Details

EnsureCanConnectToDomain()

Throws an exception if the connection to the specified domain fails.

void EnsureCanConnectToDomain(string domainName)

Parameters

  • domainName – the fully-qualified name of the domain.

GetAzureInitialDomainName()

Returns the full name of the Entra domain for the initial registration.

string GetAzureInitialDomainName(
    string tenantId, 
    string applicationId,
    string secret, 
    AzureNationalCloud nationalCloud)

Parameters

  • tenantId – the identifier of the Microsoft Entra tenant.
  • applicationId – the identifier of the application in Microsoft Entra that will be used to manage the domain.
  • secret – the client secret for the application that will be used to manage the domain.
  • nationalCloud – the national cloud where the domain is located.

Examples

The following code sample gets the initial Entra domain name and then registers the domain in Adaxes.

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

$tenantId = "9f6ad6f6-0f7c-4a8c-9f71-879bbcb6d235"
$applicationId = "0db3e0b9-6d5e-41a3-9b52-daf859129da2"
$secret = "1xYsgT7!qW94bLz@J8d#MnvP2kXeCuR0sFgUoAH3tZpLViEY6Q"
$nationalCloud = "Default"

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

# Bind to the 'Managed Domains' container.
$managedDomainsPath = $service.Backend.GetConfigurationContainerPath("ManagedDomains")
$managedDomainsContainer = $service.OpenObject($managedDomainsPath, $null, $null, 0)

# Create a new managed domain.
$initialName = $managedDomainsContainer.GetAzureInitialDomainName(
    $tenantId, $applicationId, $secret, $nationalCloud)
$managedDomain = $managedDomainsContainer.Create("adm-ManagedDomain", "DC=$initialName")

# Provide logon information.
$managedDomain.Register($tenantId, $applicationId, $secret, $nationalCloud)
C#
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string tenantId = "9f6ad6f6-0f7c-4a8c-9f71-879bbcb6d235";
        const string applicationId = "0db3e0b9-6d5e-41a3-9b52-daf859129da2";
        const string secret = "1xYsgT7!qW94bLz@J8d#MnvP2kXeCuR0sFgUoAH3tZpLViEY6Q";
        AzureNationalCloud nationalCloud = AzureNationalCloud.Default;

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

        // Bind to the 'Managed Domains' container.
        string managedDomainsPath = service.Backend.GetConfigurationContainerPath("ManagedDomains");
        IAdmManagedDomainContainer managedDomainsContainer =
            (IAdmManagedDomainContainer)service.OpenObject(managedDomainsPath, null, null, 0);

        // Create a new managed domain.
        string initialName = managedDomainsContainer.GetAzureInitialDomainName(
            tenantId, applicationId, secret, nationalCloud);
        IADsContainer container = (IADsContainer)managedDomainsContainer;
        IAdmAzureManagedDomain managedDomain = (IAdmAzureManagedDomain)container.Create(
            "adm-ManagedDomain", $"DC={initialName}");

        // Provide logon information.
        managedDomain.Register(tenantId, applicationId, secret, nationalCloud);
    }
}

Requirements

Minimum required version: 2023

See also