Assuming the user is returned in this format
domain\username
you can do the following:
string userWithoutDomain = userName.Substring(userName.IndexOf('\\') + 1);
If the format is like this
username@domain
then the following will work
string userWithoutDomain = user.Substring(0, user.IndexOf('@'));
Probably you should test which format you have and extract the user name based on that. If the user name contains neither a @ nor a \ then you just return the entire string.
No comments:
Post a Comment