0 votes

Good Morning,

I'm trying to think of a way to set the username of some of our users who have multiple first and last names. For example, Juan Carlos De Vega. The first name would be Juan Carlos and the last name De Vega. Is there any script people are using that would take a first letter of the very first name and last 7 of the very last name?

Any help would be appreciated!

Thanks

by (520 points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

You can use the BuildUsername function provided in our Script Repository: http://www.adaxes.com/script-repository ... y-s191.htm.

The code to use the 1st character of the first name and last 7 characters of the last word in last name would be as follows:

# TODO insert the BuildUsername function from the repository here

# Get last word of surname
$lastnameAsArray = "%lastname%".Split(" ")
$lastWordIndex = $lastnameAsArray.Length - 1
$lastnameLastWord = $($lastnameAsArray[$lastWordIndex]).Trim()

# Build username
$samAccountName = BuildUsername ("%givenName%", 1, "Beginning") ($lastnameLastWord, 7, "End")

# Update samAccountName
$Context.SetModifiedPropertyValue("samAccountName", $samAccountName)

# Update userPrincipalName
$userPrincipalName = $samAccountName + "@" + `
    $Context.GetObjectDomain("%distinguishedName%")

$Context.SetModifiedPropertyValue("userPrincipalName", $userPrincipalName)

Related questions

0 votes
1 answer

If the user name submitted is "jhon doe" all of the users properties will be lower case. We want it to force it to be "Jhon Doe" even if it was submitted in lower case.

asked Aug 31, 2022 by raul.ramirez (210 points)
0 votes
1 answer

We are using a custom form a property patterns to create specific contract resource accounts. We would like to know how to normalize the first and last name fields when the manager is entering them. (ex. TOM --> Tom or tom --> Tom)

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

Example: If a user has a ' in theirname: Fred J O'neal. Normally the username is set as %lastname:lower,4%%firstname:lower,3%%initials:lower% Problem is o'nefrej would be the result. ... name", "Information") $username = #this is what I'm not sure how to do?

asked Dec 6, 2022 by mightycabal (1.0k 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)
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)
3,342 questions
3,043 answers
7,764 comments
544,930 users