Skip to content

IAdmO365Account2

The IAdmO365Account2 interface extends the IAdmO365Account interface.

Inheritance: The IAdmO365Account2 interface inherits from the IAdmO365Account interface.

Methods

  • Method

  • Description

  • GetOffice365Properties2()

  • Returns 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.

Details

GetOffice365Properties2()

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

IAdmO365AccountProperties GetOffice365Properties2()

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.

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

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

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

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

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

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

        // Bind to the user
        IAdmO365Account2 user = (IAdmO365Account2)admService.OpenObject(userPath, null, null, 0);

        // Get Microsoft 365 account properties
        IAdmO365AccountProperties microsoft365Properties = user.GetOffice365Properties2();

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

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

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

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

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

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.

Boolean ValidateServices(String skuPartNumber, 
                         IAdmO365Service[] 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.


Requirements

Minimum required version: 2018.2

See also