0 votes

Using a custom command I am trying to move a user based on a template's OU. I imagine I have to use a script instead of a the built in move? I found a script in your repository that moves the user to the user's manager but I need to use template user's ou. the Parameter is param-Template.

by (1.0k points)
0

Hello,

Yes, you are right, it can only be done using a script. What exactly do you mean by template’s OU? Do you need to move the target user to an OU where a user selected in the parameter is located? What is the type of the parameter? Any additional details (e.g. screenshots of the custom command) will be much appreciated.

0

The parameter is an AD object picker which (when completed) will only allow the user to pick from a list of user accounts we use as templates. Yes we want to move the user based on the template user's current OU.

image.png

1 Answer

+1 vote
by (277k points)

Hello,

Thank you for specifying. You can use the following script:

# Get the container where the manager is located
$templateDN = New-Object Softerra.Adaxes.Ldap.DN "%param-template%"
$templateParentDN = $templateDN.Parent

if ($managerParentDN -eq "%adm-ParentDN%")
{
    return
}

# Move the user
$targetContainer = $Context.BindToObjectByDN($templateParentDN)
$targetContainer.MoveHere($Context.TargetObject.AdsPath, $NULL)

Related questions

0 votes
1 answer

Can I edit my buisiness rule from "after creating a user" to "after moving a user". I wanted to move 120 business rules and not have to recreate each one, one by one. Maybe there is a powershell script or something?

asked Oct 12, 2022 by raul.ramirez (210 points)
0 votes
1 answer

seting up a scheduled task to move users to thier correct OU. For some we can do this based on employee type and direct to a specific OU. For most of our users we will have to script this to move to the manager's OU.

asked Apr 12, 2023 by mightycabal (1.0k points)
0 votes
1 answer

I have setup a form to allow HR to edit some details on AD accounts. Currently the scope is limted to only AD object under one pre-chosen OU. The other option is an ldap filter. How can I allow this action to display user accounts from two seperate OU

asked Nov 18, 2019 by ice-dog (170 points)
0 votes
1 answer

I have tried it using the Custom Commands Action "Add the user to a group", which only allows me to add the user to one group at a time, and can't use the multiple DNs that the ... I can't get it to work. Could you assist me in finding the best way to do this?

asked Jan 16 by dominik.stawny (210 points)
0 votes
1 answer

Using this built in function: There is no option to change the domain on the user account, however this is not the domain we use for UPN. However after creating a user, you can change it but trying to avoid going back into the object.

asked Apr 14, 2023 by mightycabal (1.0k points)
3,411 questions
3,108 answers
7,912 comments
545,843 users