You guys might also consider parsing a string input like "[email protected]", or "user@domain".
This is what I'm currently doing:
If string contains '\' then split string at '\' and extract username and domain
Else If string contains '@' then split string at '@' and extract username and domain
Else treat string as username without a domain
I'm still hunting for a better solution in the case where the input string isn't in an easily predicted format, i.e. "domain\user@domain". I'm thinking RegEx...
Update: I stand corrected. My answer is a bit of out context, it refers to the general case of parsing username and domains out of user input, like in user login/logon prompt. Hope it still helps someone.