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.
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.
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:
A UPN that contains more than one @ sign is invalid.
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.