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 (50 points)

1 Answer

0 votes
by (216k 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 (240 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 (40 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 (50 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 (520 points)
0 votes
1 answer

Hello team, our users are created by HR system into AD and have the start date as string in extensionAttribute2 with a prefix (like "startdate_2024-01-02"). Sometimes the user ... "Employee" Do you have a script in place to achieve this? Thanks in advance.

asked 1 day ago by wintec01 (1.1k points)
3,326 questions
3,025 answers
7,724 comments
544,675 users