How to use a wildcard in "Location" property of a "Create User" Active Directory activity?

Okey, I’ve found a way to do it, it works perfectly!! Just a little bit slow, it takes 16 seconds, but it doesn’t matter too much.

If anyone needs to do something equal or similar, here you have a way to do it:

  1. I use a “Get Objects by Filter” activity where I search for all “OU” (active directory folders, you can find AD attribute Distinguished Names here: Distinguished Names | Microsoft Learn) that are equal to “Users” so it gives me the list with all the Distinguished names of those folders.

image

image

  1. I loop (with an “If” activity for the filter) inside the list with a “For Each” activity to search if one of those results match the code of my team (Note: for this, in my company, I need to check only inside the first 22 characters of the Distinguished Names because some of our folders are contained inside other team folders so if I check the whole string I will have more than one result because it sometimes matches with the parent folder):

image

  1. On the “Then” part of my “If” activity, I’ve created a boolean variable named UsersFolderExists that will be False by default and will only be changed to True if we have a match here (that means our folder have a “Users” subfolder inside it) AND I will assign our Distinguished named that matched the condition to a string variable named UserFolder:

image

On the “Else” part we don’t have anything because we will find a lot of “User” folders that don’t match the condition in our AD and we don’t want any action to be performed for those folders.

  1. After that, I have an “If” activity that will execute actions only in case that we don’t had any match on the previous activity because it means that our team folder don’t have any “Users” subfolder inside. In this activity I use a “Get Objects by Filter” activity that will search for any folder existing on our Active Directory that contains the code of our team (we will allways have a unique result because we don’t have more than one folder with the same team code), so, after, I assign its Distinguished Name to our variable UserFolder:

image

  1. I build a Data Table with User properties (First Name, Last Name, E-mail Address…), for this I used the EmployeeOnboarding.zip that I found on the topic IT Automation Activities for Active Directory Domain Services as template.

  2. Finally, I use the “Create User” activity using our variable UserFolder (that we filled with the correct dynamic Distinguished Name of the folder where we need to creat this user) as Location property:

image

Here you can see the complete Workflow view:

image

I hope this info will be usefull for someone!! :blush: :crossed_fingers:t2: :crossed_fingers:t2:

1 Like