IAdmM365Account

The IAdmM365Account interface is designed to manage properties of a Microsoft 365 account associated with a user.

Methods

  • Method

  • Description

  • GetMicrosoft365Properties()

  • Returns properties of the Microsoft 365 account associated with the user.

  • SetMicrosoft365Properties()

  • Sets properties of the Microsoft 365 account associated with the user.

  • ValidateServices()

  • Returns a value indicating whether the given Microsoft 365 services can be enabled when the specified Microsoft 365 license is assigned to a user.

Properties

  • Property

  • Description

  • AssociatedTenantDN

  • Gets the distinguished name (DN) of the Microsoft 365 tenant associated with the user.

Details

GetMicrosoft365Properties()

Returns properties of the Microsoft 365 account associated with the user.

IAdmM365AccountProperties GetMicrosoft365Properties()

Examples

The following code sample outputs location, sign-in status, assigned Microsoft 365 licenses and services for the Microsoft 365 account associated with a user.

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

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"

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

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Get Microsoft 365 account properties
$microsoft365Properties = $user.GetMicrosoft365Properties()

# Location
Write-Host "Location:" $microsoft365Properties.Location

# Sign-in status
Write-Host "Sign-in blocked:" $microsoft365Properties.SignInBlocked

# Licenses
$licenses = $microsoft365Properties.Licenses
Write-Host "Licenses:"
foreach ($license in $licenses)
{
    if (-not($license.Assigned))
    {
        continue
    }
    
    # License display name
    Write-Host "`t" $license.Sku.DisplayName

    # Assigned services
    $serviceAssignments = $license.Services
    foreach ($serviceAssignment in $serviceAssignments)
    {
        if ($serviceAssignment.Assigned)
        {
            # Service display name
            Write-Host "`t`t" $serviceAssignment.Service.ServiceDisplayName
        }
    }
    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 string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";

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

        // Bind to the user
        IAdmM365Account user = (IAdmM365Account)service.OpenObject(userPath, null, null, 0);

        // Get Microsoft 365 account properties
        IAdmM365AccountProperties microsoft365Properties = user.GetMicrosoft365Properties();

        // Location
        Console.WriteLine("Location: " + microsoft365Properties.Location);

        // Sign-in status
        Console.WriteLine("Sign-in blocked: " + microsoft365Properties.SignInBlocked);

        // Licenses
        IAdmM365License[] licenses = microsoft365Properties.Licenses;
        Console.WriteLine("Licenses:");
        foreach (IAdmM365License license in licenses)
        {
            if (!license.Assigned)
            {
                continue;
            }

            // License display name
            Console.WriteLine("\t " + license.Sku.DisplayName);

            // Assigned services
            IAdmM365ServiceAssignment[] serviceAssignments = license.Services;
            foreach (IAdmM365ServiceAssignment serviceAssignment in serviceAssignments)
            {
                if (serviceAssignment.Assigned)
                {
                    // Service display name
                    Console.WriteLine("\t\t" + serviceAssignment.Service.ServiceDisplayName);
                }
            }
        }
    }
}

SetMicrosoft365Properties()

Sets properties of the Microsoft 365 account associated with the user.

void SetMicrosoft365Properties(IAdmM365AccountProperties properties)

Parameters

The properties parameter specifies which Microsoft 365 account properties are modified, and their values.

Remarks

You can create an instance of the IAdmM365AccountProperties interface using the AdmO365AccountProperties class. Alternatively, you can call the GetMicrosoft365Properties. method to retrieve current Microsoft 365 properties of the user account.

Examples

The following code sample revokes all Microsoft 365 licenses and blocks user access to their Microsoft 365 account.

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

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"

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

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Create an instance of the AdmO365AccountProperties class
$microsoft365Properties = New-Object "Softerra.Adaxes.Adsi.CloudServices.Office365."

# Revoke all licenses
$microsoft365Properties.RevokeAllLicenses = $true

# Set sign-in status to Blocked
$microsoft365Properties.SignInBlocked = $true

# Modify Microsoft 365 account properties
$user.SetMicrosoft365Properties($microsoft365Properties)

# Commit changes
$user.SetInfo()
C#
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Adsi.CloudServices.Office365;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.CloudServices.Office365;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";

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

        // Bind to the user
        IAdmM365Account user = (IAdmM365Account)service.OpenObject(userPath, null, null, 0);

        // Create an instance of the AdmO365AccountProperties class
        IAdmM365AccountProperties microsoft365Properties = new ;

        // Revoke all licenses
        microsoft365Properties.RevokeAllLicenses = true;

        // Set sign-in status to Blocked
        microsoft365Properties.SignInBlocked = true;

        // Modify Microsoft 365 account properties
        user.SetMicrosoft365Properties(microsoft365Properties);

        // Commit changes
        IAdmTop user2 = (IAdmTop)user;
        user2.SetInfo();
    }
}

ValidateServices()

Returns a value indicating whether the given Microsoft 365 services can be enabled when the specified Microsoft 365 license is assigned to a user.

bool ValidateServices(string skuPartNumber, 
                         IAdmM365Service[] services, 
                         out string warning)

Parameters

  • skuPartNumber - Specifies the name of the Microsoft 365 license (e.g. ENTERPRISEPACK).
  • services - Specifies an array of Microsoft 365 services.
  • warning - An output (OUT) parameter that returns an error message when the method returns false. If the method returns true, the parameter is null.

Return value

The method returns false if the specified Microsoft 365 services require other services that are not set in the services parameter. For example, the Office Online service requires the SharePoint Online service.


AssociatedTenantDN

Gets the distinguished name (DN) of the Microsoft 365 tenant associated with the user.

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

Requirements

Minimum required version: 2023

See also