0

I want to get the domain name and username.

I want it to return domainname\username forexample: Cool\Beans

My application is linked to both an internett and a locally runned program.

When i run it locally(as an application) it returns The correct domainname and username. feks: Cool\Beans That is when im using:

Environment.UserDomainName +"\\"+Environment.UserName

or when im using

WindowsIdentity.GetCurrent().Name 

When im trying to use this in the internett application it returns. Workgroup\Cool$

I have tried to use HttpContext.Current.User.Identity.Name it returns null

Anyone have any ideas??

Thanks for answers

Andre Mesel
  • 113
  • 1
  • 9

1 Answers1

0

Environment.UserName/UserDomainName will return info for the executing user. This will return the correct user info when running an application locally but in the case of a website running on IIS, this would get the info for the user used by IIS.

Take a look at this for windows authentication Windows Authentication for ASP.NET MVC 4 - how it works, how to test it

Community
  • 1
  • 1
Jammerz858
  • 1,605
  • 3
  • 14
  • 14