Get Domain User ID in ASP.NET

后端 未结 2 458
温柔的废话
温柔的废话 2020-12-18 12:46

I have a ASP.NET application where an employee logs into Windows and then they have to select their name from a long list of names and log in into the application.

W

2条回答
  •  天命终不由人
    2020-12-18 13:22

    I was having an related issue where my local build was recognizing the WindowsIdentity.GetCurrent().Name.ToString() value as my Windows account name, but when I accessed the website via a server it was always "DefaultAppPool".

    I was able to get this to work by doing the following:

    1. Open IIS and navigate to my website.
    2. Under the IIS sections, double click "Authentication".
    3. From there, disable "Anonymous Authentication" and "Forms Authentication".
    4. Enable "Windows Authentication".

    From there I was able to discern the user id/name and proceed with my coding. I had to rework a little bit, but it was well worth it. Thanks for the advice!

提交回复
热议问题