I am developing an asp.net application with Windows authentication. User.Identity.Name seems to return the logged in user in the form MACHINENAME\USERNAME.
I would like to use this to access a database of user specific settings but what happens if the user logs on from a different machine, then the MACHINENAME part will be different. So can I simply take the USERNAME part and ignore the MACHINENAME part? Is the format of User.Identity.Name always MACHINENAME\USERNAME for Windows authentication?
Thanks,
AJ
More specifically,
User.Identity.Namereturns in the format[Domain]\[User]If your users are showing up as different domains when they access from different machines, then they are in fact different user accounts. You may be able to strip out the
[Domain]part, but that means that if anybody on a machine (domain) connects as a user with the same name as a user on a different machine (domain) then the system won’t be able to tell them apart. This may be “fine, for now” in your scenario, but it’s definitely not good practice.