SureSMS

  1. Home
  2. /
  3. Integrations
  4. /
  5. SMS integration to LDAP...
  6. /
  7. SMS integration for Entra...

Table of contents
    Add a header to begin generating the table of contents

    SMS integration Entra ID via CSV file

    Azure AD

    What is Entra ID also known as Active Directory?

    Microsoft Entra ID, formerly known as Azure Active Directory (Azure AD), is a cloud-based identity and access management service from Microsoft. This service helps organizations manage and secure user access to applications and data across a modern hybrid IT infrastructure. By using Microsoft Entra ID, organizations can offer single sign-on (SSO) and multi-factor authentication to protect user identities and improve security. The integration with Microsoft Entra ID and your Active Directory (AD) makes it possible to synchronize and manage identities centrally, simplifying user management and access control. This is essential for organizations that want efficient and secure access management.

    Pay attention to ....

    There are a few things you should be aware of before you start creating an SMS AD integration with SureSMS.

    GDPR

    The first thing you need to be aware of is that SureSMS gets access to personal data from you. This means that we are now starting to process data for you and thus we must, incomply with GDPR, have a data processing agreement.

    Phone numbers

    The phone numbers we need to send to must be in your AD. In order for us to send SMS to a person, we need to know their phone number. Therefore, if you don't have phone numbers in your AD, either get it or don't do an integration.

    Deleting contacts

    The integration is a "one-way" integration. This means that we only read from information from AD. The integration takes all people from your AD, so to speak. So, for example, if you delete a person in SureSMS, they will only come back if they are still in AD. It's always AD that has the correct data.

    How to set up your Entra ID integration

    We have several options when it comes to EntraID integration. This article describes how the integration is done via a CSV file.

    In general, the solution is based on a small script that runs on your premises (i.e. within the security mechanisms your company has established). The script creates a comma-separated file with content about people, phone numbers and groups, and this file is sent securely via sFTP to SureSMS. SureSMS then automatically loads the file into the account associated with the integrations.

    So, let's get started.

    How it works

    The process is built around a PowerShell script that performs the following tasks:

    1.Securely connects to Microsoft Entra ID using the Microsoft Graph API.
    2.Getting members from one or more specified user groups.
    3.Extracts relevant data (Name, Country code, Phone number) and the name of the group they belong to.
    4.Formatting data in a CSV file compatible with the SureSMS platform.
    5.Automatically uploads the CSV file to the SureSMS sFTP server (sftp.suresms.com).

    Once the file is uploaded, it is automatically imported to the contacts of your address book in SureSMS.

    CSV file format

    The script generates a CSV file with a semicolon as separator, which is standard in Denmark. The file contains the following columns:
    Column
    Description
    Example of an example
    Name
    User's full name from Entra ID
    Anders Jensen
    Country code
    Dialing code with + prefix
    +45
    Phone number
    Mobile number or work phone
    12345678
    Group of products
    The name of the Entra ID group the user belongs to
    IT department
    An example of the file content could look like this:
    "Anders Jensen";"+45";"12345678";"IT-Afdeling"
    "Maria Nielsen";"+45";"87654321";"IT-Afdeling"
    "Peter Hansen";"+45";"11223344";"Sales."
    "Johan Svensson";"+46";"701234567";"Salg"

    Note that the script automatically converts ISO country codes (e.g. DK, SE, NO) to the correct dialing format (+45, +46, +47) and removes any country code prefixes from the phone numbers.

    Prerequisites

    Before you can use the script, make sure your system meets the following requirements:

    • Windows PowerShell 5.1 or higher (included in Windows 10 and 11).
    • Required PowerShell modules: The script will automatically try to install Graph and Posh-SSH, if they are not already installed. This requires administrator rights the first time.
    • Permissions in Entra ID: The user running the script must have permission to read user and group information via Microsoft Graph. The first time the script is run, you will be asked to consent to these permissions.
    • sFTP access to SureSMS: You need a username and password for the SureSMS sFTP server.

    Step-by-step guide

    Follow these steps to configure and run the script.

    Step 1: Download the script

    First you need to download The PowerShell script. Save the file Export-EntraIDUsersToSFTP.ps1 in a suitable location on your computer, for example in C:\Scripts

    Step 2: Find your sFTP details in SureSMS

    For the script to upload the file, it needs your personal sFTP login details from SureSMS. The script is already configured to connect to sftp.suresms.com, so you only need your username and password.

    You can get your sFTP information by sending an email to [email protected] with information about your user number and the registered email address (see bottom left when you are logged in to app.suresms.com)

    Step 3: Run the script

    Open a PowerShell window and navigate to the folder where you saved the script. You can now run the script with the necessary parameters.

    Below is an example of how to run the script. Replace the values with your own information.

    .\Export-EntraIDUsersToSFTP.ps1 -Groups "All Employees", "IT Support" ` -SFTPUsername "ditsftp-username"

    When you run the command:

    • You will first be asked to log in to your Microsoft account to give the script access to Entra ID.
    • You will then be asked to enter your sFTP password.

    The script will now retrieve the data, create a CSV file named EntraID_Export.csv and upload it to the SureSMS sFTP server.

     

    Parameters of the script

    Here is an overview of the parameters you can use to customize the function of the script:

     

    Parameter Description
    -Groups (Required) A list of the group names from Entra ID you want to export. Separate with commas, e.g. "Group1", "Group2".
    -SFTPUsername (Required) Your sFTP username from SureSMS.
    -SFTPPassword (Optional) Password as SecureString. If not specified, you will be prompted to enter it.
    -SFTPPort (Optional) sFTP port. Default is 22.
    -SFTPRemotePath The folder on the sFTP server where the file should be uploaded. The default is /.
    -OutputPath (Optional) Changes the name or location of the local CSV file. Default is .\EntraID_Export.csv.
    -SkipSFTPUpload (Optional) If specified, only the CSV file is generated locally without uploading to sFTP.

    Examples of use

    Example 1: Export one group and upload to SureSMS

    .\Export-EntraIDUsersToSFTP.ps1 -Groups "Sales" -SFTPUsername "myuser"

    Example 2: Export multiple groups to a specific folder

    .\Export-EntraIDUsersToSFTP.ps1 -Groups "IT", "HR", "Management" ` -SFTPUsername "myuser" ` -SFTPRemotePath "/contacts"

    Example 3: Local export only without sFTP upload

    .\Export-EntraIDUsersToSFTP.ps1 -Groups "All Employees" ` -OutputPath "C:\Export\Employees.csv" ` -SkipSFTPUpload

    Automation with Windows Task Scheduler

    To keep your contact lists synchronized, you can set up a Scheduled Task in Windows that runs the script automatically at regular intervals. This ensures that new employees or changes in phone numbers are automatically reflected in your SureSMS recipient lists without any manual work.

    To create a scheduled task:

    • Open Task Scheduler in Windows.
    • Click Create basic task.
    • Give the task a name, e.g. "SureSMS Contact Sync".
    • Select how often the task should run (e.g. daily).
    • Select Start a program as action.
    • Specify exe as program and add the full path of the script with parameters as arguments.

    Example of argument:

    -ExecutionPolicy Bypass -File "C:\Scripts\Export-EntraIDUsersToSFTP.ps1" -Groups "All Employees" -SFTPUsername "myuser"

    Note: For automated driving, you need to store the password securely. You can use -SFTPPassword parameter with a SecureString stored in an encrypted file or run the script under a service account with stored credentials.