cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ToniRantanen
Level: Powered On

Create on-premises Active Directory user with Flow

Hi!

 

What would you suggest as a best workaround to create new user in on-premises Active Directory with Microsoft Flow? I understand that there is no direct connector in Flow to connect to on-premises AD but would for example On-Premises gateway or something like that be a solution for this?

 

Our target is to automate new employee process as much as possible.

 

Best regards,

Toni Rantanen

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Create on-premises Active Directory user with Flow

Hi @ToniRantanen,

 

Currently, Microsoft flow doesn’t support On-Premise Active Directly, only On-Premise SharePoint and On-Premise SQL Server are supported.

 

If you need this feature, please submit an idea on the Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas 

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Highlighted
kuingul
Level: Power Up

Re: Create on-premises Active Directory user with Flow

If you need automation for AD user provisioning, I believe you should be looking at 3rd party solutions that specialize in AD automation. Here's a good example of a solution for that: https://www.adaxes.com/active-directory_provisioning.htm

Community Support Team
Community Support Team

Re: Create on-premises Active Directory user with Flow

Hi @ToniRantanen,

 

Currently, Microsoft flow doesn’t support On-Premise Active Directly, only On-Premise SharePoint and On-Premise SQL Server are supported.

 

If you need this feature, please submit an idea on the Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas 

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

ToniRantanen
Level: Powered On

Re: Create on-premises Active Directory user with Flow

ToniRantanen
Level: Powered On

Re: Create on-premises Active Directory user with Flow

Hi @kuingul,

 

Is it possible to trigger Adaxes Active Directory Provisioning with Microsoft Flow? I'm looking for a solution where for example HR would fill new employee's details to Microsoft Forms and then Microsoft Flow would take care rest of the routine tasks related to new employee start.

 

Best regards,

Toni Rantanen

CrankyNetGuy
Level: Powered On

Re: Create on-premises Active Directory user with Flow

I have created a way to trigger the creation of an AD User with the help of a gateway.

 

I have a list in Sharepoint when HR submits a new user. It takes those values and compiles it into a csv with the necessary fields required in powershell.

 

Once the csv is created I send it to my on-prem server with the gateway to a specific folder. I have a repeating task in task scheduler set to run a .bat which calls a powershell script to monitor the folder indefinitely. That powershell script will monitor that folder for any file ending in ".csv" being created. When it triggers it sets off my CreateUser.ps1 which will import the newly created csv and create the user based on that. Once the script is ran, due to the way I'm importing the csv, it will delete that csv from the folder (I had the flow create the csv in a sharepoint docs folder as backup as well).

 

I hope I explained that well.

Anonymous
Not applicable

Re: Create on-premises Active Directory user with Flow

Would you mind sending me the script that you used to do that? I've been thinking through this problem today - and I think this might be the best solution tbh. Great idea!

 

Were you able to take unique passwords for the users or were they all the same password for each user created? 

CrankyNetGuy
Level: Powered On

Re: Create on-premises Active Directory user with Flow

I was able to create a unique password for each user. When creating the csv I used a randomly generated GUID and grabbed the first x number of characters and set that for the password field.

 

The script to monitor is fairly simple:

 

$folder =  # Enter the root path you want to monitor. 
$filter = '*.csv'  # You can enter a wildcard filter here. 

$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}

Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { 

Invoke-Item 'Folderpath.bat'
}

 

Since I am not logged onto a server 100% of the time I set a task schedule to call a .bat which will open up this script with a persistent window (as it requires an active PS window). That is done with a .bat (ran every 5 minutes through Event Scheduler to ensure it stays up)

 

Powershell.exe -noexit "& "Path.ps1

The "Folderpath.bat" mentioned in the first block of code with "Invoke-Item" is what invokes this 

Powershell.exe -executionpolicy remotesigned -File Path-To-Create-User.ps1

That .ps1 is my create AD user script. You can find plenty of guides on how to customize that to your needs. The important parts (for this method anyway) is that you need it to run right as the .csv is entered and then delete the .csv as it pulls every csv in the folder. I'm sure you could do a foreach but I'm too lazy for that and this works perfectly fine as I have a backup of the csv in a SharePoint drive.

 

Just start the create-user.ps1 like this:

Import-Module ActiveDirectory

$CSVPath = Get-ChildItem C:\Path-To-Folder-With-CSV -Filter *.csv | select -ExpandProperty FullName
$User = Import-Csv -Delimiter "," -Path $CSVPath

And do a 

Remove-Item -Path $CSVPath

To delete the csv that was just created.

 

I hope that is clear enough to follow, I'd be happy to clarify or help further if I can.

Anonymous
Not applicable

Re: Create on-premises Active Directory user with Flow

Thank you so much!! This is great. 

 

Do you know how you ensure that a csv isn't deleted in the case of 2 simultaneous users created in the SharePoint form? 

 

How do you make sure it only deletes the csv for the user you just created? 

CrankyNetGuy
Level: Powered On

Re: Create on-premises Active Directory user with Flow

At least in my situation only one user can be submitted at a time so the CSV will only be created for a single user. Since the script runs right when the csv is put into the folder you'd have to have 2 users submitted something at exactly the same second which is highly unlikely. If you can control the situation I would highly recommend only one user per form.

 

For deleting the csv you just created that will be with the $CSVPath variable as that is what it imports from.

pobblebonk
Level: Power Up

Re: Create on-premises Active Directory user with Flow

Hi,

You should be able to use powershell CSOM scripting using a package like PnP-PowerShell to wathc the sharepoint list and update the list item status once processed and also provide direct feedback if there were any issues.

 

Hope this helps.

Mat

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,972)