0 votes

Hi,
I found the following example to remove special characters from an attribute but somehow I can't get it to work.
I'm using this script in a business rule before creating the user.

$props = @("email","sAMAccountName", "userPrincipalName")
$map =@{ "å"="a"; "ö"="o"; "ä"="a";"ü"="u"; "ñ"="n"; "é"="e"; "-"=""; "'"="" }

foreach ($prop in $props)
{
    if ($Context.IsPropertyModified($prop))
    {
        $value = $Context.GetModifiedPropertyValue($prop)

        foreach ($key in $map.Keys)
        {
            $value = $value.Replace($key, $map[$key])
        }

        $Context.SetModifiedPropertyValue($prop, $value)
        $Context.LogMessage($prop + ": " + $value, "Information")
    }
}

Can someone identify what i'm doing wrong?
Incorrect if statement?

by (100 points)
0

My apologies, "sAMAccountName", "userPrincipalName are actually being done.
Email was not set correctly, I used "Email" where it had to be "mail"

Changed it and now it work, THX for the support!!

Please log in or register to answer this question.

Related questions

0 votes
1 answer

I want to remove special characters on the onboarding web form for username and mail before clicking Finish. Using a script like on the rule "Before User Creation" seems to to do the change to late and you can not verify the email adress before created.

asked Dec 27, 2021 by joem (20 points)
0 votes
1 answer

We have run into an issue where the special characters in a person's name are causing havoc with email addresses. We need to remove all special characters and only ... we want to use the FullName and remove the characters before creation. Please advise.

asked May 22, 2017 by willy-wally (3.2k points)
0 votes
1 answer

I have taken a look at the below help article for configuring password generation parameters, but I am not sure where to add this as a script in Adaxes admin ... https://www.adaxes.com/help/PasswordGenerationParameters/ Thank you in advance for all the help

asked Jan 11 by Vish539 (460 points)
0 votes
1 answer

We have been able to add email addresses using the script in E-Mail Addresses Is there a way to reverse the process and specify the smtp address you want to remove using a similar subset of code.

asked Dec 14, 2022 by martin.mcclorey (40 points)
0 votes
1 answer

$property = "mail" # TODO: modify me #$regex = "^[a-zA-Z0-9_.%%\-\+]+@([a-zA-Z0-9_\-]+\.)+[a-zA-Z0-9_\-]+$" # TODO: modify ... regular expression: $regex") # TODO: modify me #} # Update property value $Context.SetModifiedPropertyValue($property, $value)

asked Feb 25, 2020 by Derek.Axe (480 points)
3,547 questions
3,238 answers
8,232 comments
547,809 users