Mattermost Recipe: Importing Active Directory users into Mattermost channels

Here’s the next installment of a new series of posts we’re doing on the Mattermost blog: Mattermost Recipes.

The goal of these posts is to provide you with solutions to specific problems, as well as a discussion about the details of the solution and some tips about how to customize it to suit your needs perfectly.

If there’s a Recipe you want us to cook up in the future, drop us a line on our forum.

Problem:

Your enterprise is using Active Directory to manage several thousand users. You’d like to import those users into Mattermost channels to maintain the organizational units and group structures (e.g., computers, users and devices) you’ve created.

Solution:

Mattermost allows the bulk import of data into the server with a bulk_import tool which is part of the central platform command. (The details can be found here.)

The tool needs the data to be imported in a JSONL (JSON lines) format. Unfortunately, that can’t be created out-of-the-box on a Windows Active Directory server.

A PowerShell script seems to be the best option here. Here’s a script I wrote which can be easily used and forked.

Active Directory

You can change different lines to solve your use case.

For example, the search base can easily be pointed to another organizational unit or common name. You can also check the search filter as you may just want to add specific users to specific channels (e.g., all HR users to the “Onboarding” and “Interviews” channels).

Right now, the script is written to support one team and many channels which can be changed by adding another loop inside.

The result of the script is a JSONL file that can be used by the bulk import command on the Mattermost server.

Please use the –validate switch before uploading the users and keep in mind that the channel names have to be lowercase on the PowerShell import!

Active Directory

When all users are imported, they should be already part of the channels you’ve added them to with the script and import (e.g., testchannel and secondone).

Need some more help?

Check out this short demo to see exactly what needs to be done.

 

(Editor’s noteThis post was written by Christian Johannsen, Solution Architect at Mattermost, Inc. If you have any feedback or questions about Mattermost Recipe: Importing Active Directory users into Mattermost channels, please let us know.)

mm

Christian Johannsen is a former Solutions Architect at Mattermost, covering the EMEA region. Prior to joining Mattermost, Christian worked in IT for nearly 20 years and served as a VMware consultant for integration and automation. Being a specialist in the virtualization space, he wanted to get more involved with the DevOps scene. His experience in these areas is what allowed him to help customers integrate the Chef framework into new and existing environments. With these skills, he decided to focus more on ChatOps solutions and helping customers collaborate more effectively using Mattermost. Follow him on Twitter: @cjohannsen81.