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 (1.9k points)

1 Answer

0 votes
by (215k 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 (710 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 by manuel.galli (510 points)
0 votes
1 answer

Hi all, I want to create an external Username (username-ext). Loginname is the same as the initials. Changing the intiakls -> intials-ext ... CommandPipeline.Actions.ActionBase.Execute(ICommand command) --- Ende der internen Ausnahmestapel├╝berwachung ---

asked Jun 13, 2016 by massimo.ibba (2.5k points)
0 votes
1 answer

If you use the Adaxes admin tool to rename an OU, does that also update the corresponding OU information that is referenced in any policies that you have in the Adaxes Administration console. Minus and powershell/vb scripts - I assume those wouldn't updated.

asked Aug 13, 2018 by mdedmon (740 points)
0 votes
1 answer

Hi, I were unable to find a publicly available information about release dates for the next Adaxes major version, including at https://www.adaxes.com/info_roadmap.htm. Since in my ... 's mid 2020 already, when can we expect a 2020.1 version please? Thank you.

asked Jun 16 by Denys (290 points)
2,245 questions
2,007 answers
5,494 comments
19,938 users