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

I'm working on a new user creation form for the help desk. I'm having them select the department number the new hire will be in. Once user is created, I want the department name to be ... there a easier way? Example: Dept ID 1 = IT, 2 = Finance, 3 = HR etc.

asked May 15 by tromanko (330 points)
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

Hi i have created a business role in that role if user is created a specific OU it will do everyting , generate password create email in specific DataBase , but i cannot find how to ... BA , according to this ou user should get @ba.com UPN , how can i do that?

asked Nov 29 by vagifazari (450 points)
0 votes
1 answer

Is it possible to create a business unit and have it auto populate with group owners in a specific OU. I've tried a few scripts to get propertie adm-managedbylist but none have worked so far.

asked Nov 18 by C27 (20 points)
3,588 questions
3,277 answers
8,303 comments
548,084 users