0 votes

Hi

We try to achieve a script where Adaxes replaces all umlauts in the username and mail adress and also checks for duplicate usernames.

What we have so far is from questions on other topic, but we are unable to get it to work. The username and email still come with umlauts. We will not even get the log lines. Can you help us with the script?

Thanks in advance, Mario

Import-Module Adaxes

# Get the username
$username = $Context.GetModifiedPropertyValue("samAccountName")


function ReplaceCharacters($value)
{
    $map =@{ "å"="a"; "ö"="oe"; "ä"="ae";"ü"="ue"; "ñ"="n"; "é"="e"; " "=""; "'"="" } # TODO: modify me

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

    return $value
}
$username = ReplaceCharacters($username)


function IsUserNameUnique($username)
{
   $user = Get-AdmUser $username -erroraction silentlycontinue
   return $user -eq $Null
}


# Check if it is unique
if (IsUserNameUnique($username))
{
    return
}



# If the username is not unique, add a digit to it
$uniqueUsername = $Null
for ($i = 1; $True; $i++)
{
    $uniqueUsername = $username + $i
    $uniqueUPNName = $username + $i
    if (IsUserNameUnique($uniqueUsername))
    {
        break
    }
}


$uniqueUPNName = ReplaceCharacters $uniqueUPNName
$Context.LogMessage("The username is " + $username + "", "Information")
$Context.LogMessage("The UPN is " + $uniqueUPNName + "", "Information")

# Update User Logon Name (pre-Windows 2000)
$Context.SetModifiedPropertyValue("samAccountName", $username)

# Update User Logon Name
$upnSuffix = $Context.GetObjectDomain("%distinguishedName%")
$userLogonName = "$uniqueUPNName" + "@" + $upnSuffix
$Context.SetModifiedPropertyValue("userPrincipalName", $userLogonName)
$Context.SetModifiedPropertyValue("Description", $i)

$Context.LogMessage("The username has been changed to " + $userLogonName + ".", "Information")


$email = $Context.GetModifiedPropertyValue("mail")
$email = ReplaceCharacters $email
Context.SetModifiedPropertyValue("mailNickname", $username)
$Context.SetModifiedPropertyValue("mail", $email)
by (100 points)
0

Hello,

Can you help us with the script?

How exactly do you execute the script? Is it via a Business Rule triggering Before creating a user? Could you, please, post here or send us (support[at]adaxes.com) a screenshot of the rule? Did you make sure that the script actually gets executed?

We will not even get the log lines.

What exactly do you mean? What logs did you check?

Please log in or register to answer this question.

Related questions

0 votes
1 answer

I have modified the "Rename the user if the Full Name is not unique within the OU" and the "Automatically add a digit to the username if it is not unique" script into one ... .LogMessage("The DN has been changed to " + $modifiedDN ` + ".", "Information")

asked Jul 31, 2013 by jheisley (590 points)
0 votes
0 answers

Trying to configure a custom launcher in Thycotic Secret Server that will launch Adaxes on the user's local machine with the username and password passed as parameters. Has anyone made this work?

asked May 20, 2022 by amillard (20 points)
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

I would like to replace some characters "before user creation". With character like umlaute "ä", "ö", "ü". The script works. But characters like "é", "ô" doesn't seem to ... upn we have some issues with it in the Azure World. Do you have a solution for this?

asked Jun 20, 2023 by VinAx (50 points)
0 votes
1 answer

hello i'm new with Adaxes i'm try to creat schuadle task to import a spefice user list by thier username id after that just update City for them by bulk updating . kinly advise

asked Aug 29, 2023 by sudox (20 points)
3,346 questions
3,047 answers
7,781 comments
544,981 users