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 (294k 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

Hi there, I've created a Delete User feature in the Web Interface Configurator. I am trying to restrict object selection via a User Criteria. Need to exclude Service ... won't appear when selecting target user for the 'Delete User' feature. Thanks, David

asked Sep 19 by dshortall (80 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'm currently writing an "After User Creation" rule and I have a PowerShell script that adds the newly created, on-premises synced user to a handful of cloud ... powershell cmdlet that fails. I need to use PowerShell for the additional condtional flexibility.

asked Dec 13 by smcfarland (60 points)
3,588 questions
3,277 answers
8,303 comments
548,091 users