I am currently trying to create a function that will take a CSV file and Output a username that is available to use. Right now it checks to see if their first name is already taken as a username, if it is, I want to add the first letter of their last name and test it again. These test would continue until it finds a username that is not in use. I am having issues getting it to loop correctly. The overall goal is to import a CSV user and create an AD User with the following attributes: Name, Manager, Location, Telephone, Mobile Phone, Job Title.
It does not take the whole csv file it only takes one first name and surname pair at a time and checks the AD for the specified criteria. Try it and play a little with it.
Something to think about depending on the volume and time until the accounts are actually created, is that you are not reserving these account names. So, if there is significant time between the generation of the list and account creation, other accounts could “steal” the ID. Also, if there are 2 or more people with the same given name in your CSV, you will return the same result for both. A better approach would be to attempt to create a placeholder, catching errors until it succeeds. Give them a special description, and you can clean up the unused ones if they are not converted to real accounts after a certain amount of time has passed.
Coming from an Access Management realm myself, I would highly suggest against using properties like a users name to build user id’s, as they will quickly become painful to manage, as you’re already seeing in trying to find unused network id’s.
you may find yourself better served to find a truly distinct identifier for your users and utilize that to build your id’s.
unfortunately, you do have to rely on others to help (usually the HR dept)
but you will save yourself significant pain going forward, examples would be how do you handle legal name changes/marriages various other things that affect your chosen account naming standard.
I agree with you 100%. Unfortunately I do not have much control over user id creation schema. I have brought it up that we should change while we are still a smaller company and save the headache in the long run. Fingers crossed