Does anyone have a regex that checks if a string is a valid AD account name?
e.g. accounts can’t have “@” and so forth.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to Microsoft’s website the UPN naming rules are based on RFC 822 “STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES”. It also says:
Yet RFC 822 allows for more than one @, so I am misunderstanding the documentation or it is not actually based on that RFC. Assuming that it is in fact based on RFC 822 you can use this regular expression to validate the entire UPN (after stripping comments).
Or simpler: just try to create the user and see if it fails.