Skip to content

Enabling users for Skype for Business (Lync)

The following code sample enables a user for Skype for Business.

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

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

# Bind to the user
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Enable the user for Skype for Business
$user.LyncEnable("lyncserver.domain.com", "sip:jsmith@domain.com",
    "ADM_LYNCTELEPHONYMODE_PC2PC", $null, $null)
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Adsi;
class Program
    {
        static void Main(string[] args)
    {
        // Connect to the Adaxes service
        AdmNamespace adsNS = new AdmNamespace();
        IAdmService admService = adsNS.GetServiceDirectly("localhost");

        // Bind to the user
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IADs user = (IADs)admService.OpenObject(userPath, null, null, 0);

        // Enable the user for Skype for Business
        lyncOps = (IAdmLyncOps)user;
        lyncOps.LyncEnable("lyncserver.domain.com", "sip:jsmith@domain.com",
            ADM_LYNCTELEPHONYMODE_ENUM.ADM_LYNCTELEPHONYMODE_PC2PC, null, null);
    }
}

See also