Peter Mortensen StackTrace StackTrace 8, 33 33 gold badges silver badges bronze badges. Use Windows authentication. Otherwise how will the browser know, and why would it send to the server, what Windows user is logged in?
CodeCaster, should i take it its completely impossible using forms authentication?. The applications uses roles for controlling access levels but i would like to get current windows account for some back end auditiong — StackTrace. Roles are not bound to a specific authentication method, you can use them with Windows authentication as well. Is this an intranet application? Add a comment. Active Oldest Votes. Improve this answer. Zo Has Zo Has 12k 20 20 gold badges 81 81 silver badges bronze badges.
Hi,i have two modules in same project i. Client website has login page and admin module use windowsAuth mode.. How do I disable anonymous users in authorization tag? To get the currently logged in user to a Windows account you have to use Windows authentication instead of Forms authentication : System.
Dawid Dziadkiewicz Dawid Dziadkiewicz 2 2 silver badges 8 8 bronze badges. ToString ;. Abhishek Jaiswal Abhishek Jaiswal 1, 12 12 silver badges 5 5 bronze badges. Then, I called the following variable to return the name of the logged in user on windows: HttpContext. Substring HttpContext. I use this: System. LogonUserIdentity ; this. YaakovHatam YaakovHatam 2, 2 2 gold badges 21 21 silver badges 37 37 bronze badges. Is this still getting the current logon windows authentication in computer when it is deployed in IIS?
Postback Postback 1 1 gold badge 8 8 silver badges 27 27 bronze badges. Rohit Vyas Rohit Vyas 1, 3 3 gold badges 19 19 silver badges 28 28 bronze badges. This has taken me ages to get to the bottom of. Good luck with it. IIS is a waking nightmare! Clear ; client. Result; if response. Unescape responseString. Domain , username ; if null! Improve this answer. AddHttpContextAccessor ; services. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Connect and share knowledge within a single location that is structured and easy to search.
I work on an ASP. NET application where I need this information. So I've put my application on a server and tried the code above, and I get "Network Service" in the string opl. NET application. NET Web application. Using System. Name should work. Please check the IIS Site settings on the server that is hosting your site by doing the following:. Now System. Name should return something like this:.
The best practice is to check the Identity. IsAuthenticated Property first and then get the usr. UserName like this:. You can simply use a property of the page.
And the interesting thing is that you can access that property anywhere in your code. If you develop with ASP. So in case you get lost in some models looking for the current user, try to step back and to get the relevant information in the controller. The general consensus answer above seems to have have a compatibility issue with CORS support. In order to use the HttpContext. Name attribute you must disable anonymous authentication in order to force Windows authentication to provide the authenticated user information.
You can get around this by leaving anonymous authentication enabled and using the HttpContext. LogonUserIdentity attribute instead. This will return the authenticated user information assuming you are in an intranet scenario even with anonymous authentication enabled. The attribute returns a WindowsUser data structure and both are defined in the System. Web namespace. NTLM has to be the topmost. Further Web. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow.
0コメント