0 votes

Hi,

I would like to be able to provision my user accounts "Department" fields based on the Organizational Unit name in which the user is in.
Basically I'd like to copy the OU name in the Department user "Department" attribute.
Can you tell me which would be the easiest way to do this with Adaxes?

ex:

OU = IT Corp

Name = Paul Fakename
Department = IT Corp

Thanks in advance

by (280 points)

1 Answer

0 votes
by (215k points)
selected by
Best answer

Hello,

To accomplish your task, you need to create 2 Business Rules. One of these Business Rules will be triggered after creating a user and will populate the Department property of a new user with the name of the OU, in which the user is created. The other Business Rule will be triggered after moving a user and will populate the Department property of the user with the name of the OU, to which the user was moved. Also, as the actions performed by both the Business Rules are identical, you can create a Custom Command that contains the actions to be performed and call this Custom Command from your Business Rules. To do this:

  1. Create a new Custom Command.

  2. If you don't want to execute the Custom Command manually, you can disable it. To do this, uncheck the Enabled option on the 1st step of the Create Custom Command wizard.

  3. On the 2nd step of the wizard, select User.

  4. On the 3rd step of the wizard, add the Run a Program or PowerShell script action and paste the following script:

     $parent = $Context.BindToObject($Context.TargetObject.Parent)
     $Context.TargetObject.Put("department", $parent.Get("name"))
     $Context.TargetObject.SetInfo()
    
  5. Finish creation of the Custom Command.

  6. Create a new Business Rule.

  7. On the 2nd step of the Create Business Rule wizard, select User and AfterCreating a User.

  8. On the 3rd step of the wizard, add the Execute a Custom Command action.

  9. Click Select... and choose the Custom Command that you created in steps 1-4.

  10. Finish creation of the Business Rule.

  11. Create a new Business Rule.

  12. On the 2nd step of the Create Business Rule wizard, select User and After Moving a User.

  13. Repeat steps 8 and 9.

  14. Finish creation of the Business Rule.

0

Excellent, that is exactly what I needed.

One more thing, how can update the "Department" fiel of my existing users ? -> In the task properties just "enable" the script will do?

Best regards,
Cédric

0

Hello Cédric,

To update the Department property for existing users, you can use the Custom Command created in steps 1-5 of my previous post.

If you disabled the Custom Command on the 2nd step, you need to enable it. To enable a Custom Command, right-click it, point to All Tasks and click Enable.

Now, when the Custom Command is enabled, it appears in the right-click menu of all objects, on which it can be executed. The Custom Command described in my previous post is available for User objects, thus, when you right-click a user, the Custom Command will be available for the user in the right-click menu (under All Tasks):

Click the Custom Command to execute it on the select user. Also, you can select multiple users to apply the Custom Command in bulk. See also Modifying AD Objects in Bulk.

0

Perfect, thanks for your help. I'll test this solution before production.
Best regards,
Cédric

Related questions

0 votes
1 answer

In our organisation every department has a named manager. So if I add a new user and their department is "Sales" (selected from a property pattern) I have a business ... department. Any suggestions on the simplest way to achieve this would be great thanks :)

asked Feb 23, 2014 by hutchingsp (1.9k points)
0 votes
1 answer

During the creation of a new user I want to be able to select the job title from a drop-down list which populates different values based on which Department is selected. Is there a way to achieve this? Thanks. Dario.

asked Oct 2, 2020 by winstonsmith (450 points)
0 votes
1 answer

Is it possible to have Adaxes dynamically provide a list for the Offices AD property to choose based on a OU structure?

asked Aug 27, 2017 by audiblehum (280 points)
0 votes
1 answer

For licensing purposes is it possible to restrict users displayed in Adaxes based on an OU rather than individual accounts?

asked Jun 17, 2013 by bemho (3.8k points)
0 votes
1 answer

We would like to have a business unit that is based on an adaxes custom attribute. I don't see a way of doing this. Do you all have any ideas?

asked May 18, 2020 by mark.it.admin (7.1k points)
2,447 questions
2,198 answers
5,913 comments
294,858 users