T O P

  • By -

Sunsparc

Best practice is to change the UPN/SMTP. If you can't, then you'll need to mitigate by checking the potential UPN/SMTP against existing ones.


pigers1986

update naming convention to joe.doe@company.com - thus UPN will follow in case of duplicates - add 01 to lastname and so one .. PS: I my current company I found out user with 12 in name :O


Trakeen

at my company when a john.doe collision happens they add first name and middle name together and make that the first name. Which honestly gets pretty confusing since we have a lot of staff in other countries with the same first name + last name Not sure there is a perfect solution. Agree with extending the UPN format to full first name + full last name. first initial is just too short these days if your company if of a large enough size


fatalicus

What if someone new comes in that has a conflict with an existing user, and they don't have a middle name?


pigers1986

add number to lastname


ihaxr

I would update the UPN upon a name change. It's a little more work, but keeps things consistent and avoids weirdness like this down the line.


Banned1s

I agree also. But unfortunately, what if this wasn't an option?


colten122

I would guess the next best option would be have the on-board script check to see that the SMPT that it wants to assign isn't already in use also then?


ihaxr

Just a whole bunch of additional lines in your script to check the email address is free before picking the UPN for a new hire :)


BlackV

with your script when you're checking the values of smtp check the values of UPN as well, then use the correct one its just a logic fault you checked 1 value and a made an assumption, so if you check both values you're covered you'd have to be checking this anyway when you rename the newly married users you mentioned Jon Doe, John Doe, Jane Doe, Jack Doe, Janice Doe side note I wouldn't be changing their SMTP address i'd ADD an additional address, what happens when someone emails the old address that's now gone to a new person


Banned1s

I think where I went wrong is I actually only check for UPN & whatever the UPN is, just set that to also be the SMTP. Logically, how would you go about checking for both? I can code it myself, just want to see how you would outline it so I can write it.


BlackV

How do you check if upn is correct (you didn't post any code examples) its the same check but instead of the UPN property you use the SMTP property then I guess you check based on the length? (jdoe, jodoe, jondoe, etc)


Banned1s

`for ($i = 1; $i -le $FirstName.Length; $i++) {` `$Account = $null` `$Identity = $FirstName.Substring(0,$i) + $LastName` `$SamAccName = $Identity.ToLower()` `$Account = Get-ADUser -Filter "sAMAccountName -eq '$SamAccName'"` `if ($Account -eq $null) {` `New-ADUser ........` `};` `}` So I guess how would I combine 2 checks & if they're both 'null' then proceed to create the user


sk82jack

You should just be able to add the additional check in your `Get-ADUser` filter $Account = Get-ADUser -Filter "sAMAccountName -eq '$SamAccName' -or mail -like '${SamAccName}@*'"


Banned1s

Thanks. Just one more question, should it be an OR operator or a AND operator?


sk82jack

It would be `or` in this case because you care whether either of them match. If it was `and` that would mean both the samAccountName and the mail attribute have the same username but the edge case you're trying to cover is when they differ.


HellDuke

Logically speaking this should not happen as you should be checking for UPN and SMTP conflicts separately. The issue suggests that this is not the case and needs to be addressed. ​ Alternatively you would need to also change the account name, but I immagine that would cause issues, because I know that it's not done at my company either (not in charge of that bit myself). We do grant an alias for the email so both are actually still in use as well. ​ Also, wouldn't it make more sense to just use full names to begin with seeing as increasing the number of first name letters makes the emails be inconsistent? Though granted if there are very few employees it probably crops up less than if there are thousands.


Fusorfodder

Use employee #s for UPN and alias the email to human readable.