0 votes

Another question :roll:

When updating a user account, in case of username's change, I would like to run a script with variables like the old username value and the new one.
I do not see how to call the old value.
Is it possible?

Thank's in advance,
Yoann

by (180 points)

1 Answer

0 votes
by (216k points)

Hello Yoann,

Yes, this is possible. Here's a sample:

$oldValue = $Context.TargetObject.Get("sAMAccountName")
$newValue = $Context.GetModifiedPropertyValue("sAMAccountName")

Please, keep in mind that such a script should be run before updating a user account. After you update the account, both the $oldValue and the $newValue will contain the current username.

0

I think this is for Powershell scripts.

Is there the same for DOS ?

0

Hello Yoann,

What do you mean by 'DOS'? Do you want to use these values to run an external program? Please, describe in more detail what you are trying to accomplish.

0

Finally, it's ok.

I've done this :

$oldValue = $Context.TargetObject.Get("sAMAccountName")
$newValue = $Context.GetModifiedPropertyValue("sAMAccountName")
$path = "\\FILER\home_users$\"
if (Test-Path $path$oldValue)
    {
        C:\xxxxxx\Rename_HomeDir.cmd $oldValue $newValue
    }

In Rename_HomeDir.cmd file, I just have a rename DOS command.

0

Hello Yoann,

This will work OK.

However, take a look at the Rename User Home Directory built-in Business Rule. It does approximately the same. We think, this is a better option.

0

I've seen this option but for particular reasons, we do not use the home directory attribute but a special one that we created by a schema extension.

Thanks for your help.

0

Try this one. This will do without the .cmd file.

$oldValue = $Context.TargetObject.Get("sAMAccountName")
$newValue = $Context.GetModifiedPropertyValue("sAMAccountName")
$path = "\\FILER\home_users$\"
if (Test-Path $path$oldValue)
    {
        Rename-Item $path+$oldValue $newValue
    }
0

Hello,

Yes, it's easier.
Thanks

Related questions

0 votes
1 answer

Dear Is it possible to change the values of a custom attribute (adm-CustomAttributeTextMultiValue4) when selecting a value from another custom attribute (adm-CustomAttributeText1). For ... , 2Latijn, 3Latijn, etc... Is this possible? Sincerly Hilmi Emre Bayat

asked Aug 26, 2019 by hilmiemrebayat (120 points)
0 votes
1 answer

Hi, is it possible to save to an Adaxes attribute the value of the last Sign In from Azure AD? When we query users for Last Logon, we, of course, can only see the Last Logon value from AD It would be very useful to know the latest login in Azure AD as well

asked Jun 22, 2020 by manuel.galli (100 points)
0 votes
1 answer

Is there a way to have the Create User trigger to run a command to trigger the update user flag/trigger to be hit? The goal is to have specific Create User tasks to also go through the same tasks as the Update user.

asked Mar 2, 2023 by mobosys (290 points)
0 votes
1 answer

I am trying to trigger processing outside of Active Directory when an account is created based on the source user account that was used. Does Adaxes store the source account anywhere?

asked Oct 9, 2023 by jnordell (20 points)
0 votes
1 answer

How can i différenciante the two user without opening each one of them ?

asked Jan 20, 2023 by eric.lebrun (20 points)
3,326 questions
3,026 answers
7,727 comments
544,682 users