Walkthrough Guide on How to Use Teams-to-AD Directory Sync Application

What does the application do?

It will connect to your Teams tenant, grab the assigned Teams Calling Numbers (known as LineURI) of all users and then update the telephoneNumber attribute of those users in On-Premises AD.

Prerequisites

  • Java 11 or higher

  • PowerShell 7.2

  • Installed PowerShell Modules:

    • MicrosoftTeams 4.3.0

      Command to install:

      Install-Module -Name MicrosoftTeams -RequiredVersion 4.3.0

       

    • ActiveDirectory

      Command to install:

      Add-WindowsCapability -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 -Online

Encrypting Account Passwords

In order to run the app, you will need to provide some configuration properties required for the application to run. These include usernames and passwords for the following:

  • AD account with read/write access to the server and user search base

  • Teams Administrator account with MFA disabled

For increased security you should encrypt your passwords to avoid having them displayed in plain-text inside the application properties file.

Follow the steps below to encrypt this sensitive information.

  1. Open a new command prompt.

  2. Inside the shell, navigate to the directorysync folder (ex: \Users\s8support\Desktop\directorysync)

  3. Run the encryptor application by typing .\bin\encryptor.bat -e

  4. Follow the instructions provided to generate encrypted values for each of your passwords

    How to Generate the Encrypted Password Value

You are now ready to create and configure your application properties file using your encrypted password values.

Configuration (Application Properties)

  1. Create a file named application.properties in the same directorysync folder

  2. Copy-paste the properties below to the file.

    directorysync.msteams.credentials.username = directorysync.msteams.credentials.password = directorysync.ad.credentials.username = directorysync.ad.credentials.password = # If windows server is not on the domain, please uncomment below and provide domain controller fqdn # directorysync.ad.settings.server = directorysync.ad.settings.search_base = directorysync.ad.settings.extension_attribute = directorysync.ad.settings.phone_number_attribute = directorysync.logging.history_max_days =
  3. Fill out the required properties.

    1. To use the encrypted passwords in the file, you will need to wrap the encrypted string with ENC(<encrypted string>) (See example below)

       

How to Run the App From the Shell

  1. Open a new command prompt

  2. Inside the shell, navigate to the directorysync folder

  3. Type .\bin\directory-sync.bat and hit ENTER

The application will initiate and run through the following tasks:

  • Connect to Microsoft Teams and find all users who have a LineURI configured
    Be patient, this process can take up to several minutes depending on the volume of Teams Calling users in your environment.

  • Update those users telephoneNumber attribute in local AD if the information is not up to date.

  • Provide tally of the total number of updated users.

Log Output

The logs will be generated in a folder named logs located in the same directorysync folder..


How to Run the app from a different folder than the one containing the file

You will need to provide the path to the application.properties file by adding the spring.config.additional-location command line argument .

For example:

How to Set up a Windows Scheduled Task to Run the App

  1. Open Task Scheduler

  2. Select "Create Basic Task"

    1. If you need more advanced options or settings such as multiple actions or triggers, choose "Create Task instead"

  3. Provide a name and description and click “Next

  4. Set the desired trigger

    1. Select when it should start and click “Next

    2. Select when it should recur and click “Next

       

  5. When selecting the action, choose "Start a program" and click “Next

  6. Provide the required fields and click “Next

    • "Program/Script": Use the the file browser to navigate to the directory-sync.bat file located in the \directory-sync\bin folder

    • "Add arguments": Leave empty

    • "Start in": <Path to directorysync folder>
      If the path contains whitespace, you will need to surround the path with double-quotes (")

  7. Click “Finish