We help IT Professionals succeed at work.

Get Current User's windows identity

gautam_reddyc
on
i have an asp.net application which requires user's current name.
when the use the below code.. it runs well on my local machine and gives my username.. however when i deploy the application on server.. it returns NTAUthority\IUSR.
can any one tell me..why does that happen??
how to handle this issue? Please help
Comment
Watch Question

Top Expert 2010
Commented:
Howdy

What you are getting is the username of the context executing your code, in this case its IIS and why it works perfectly on your local machine.

If it is the Windows user you are looking for and the authenication mode for the web app is set to Windows you can do something like.

Split(HttpContext.Current.User.Identity.Name,"\")

where that should give you the daomain name and username

I hope that starts you off in the right direction
hi kris and james,
    Thanks a lot.. it is working gr8.
   do you guys have any idea how to change the url to someting like http:// appname.com
instead of http://localhost/default.aspx