Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid. Related Questions. Getting Remote Windows Username on Intranet. How to Get loggedin user from session. Want to use firstname from userinfo table instead of username from aspnetusers table in ASP. NET identity loggedin info in web form application. Session Timeout Problem in asp.
Custom authentication to limit access to intranet web application pages. Intranet ASP. NET website windows authentication not working.
Get username client side C. What 'authentication method' is required for an intranet site. No need for extra function or mess. I hope this helps someone.
Make sure that you have enable windows authentication. If you have anonymous authentication enabled you may be getting a null string. As an administrator working on other people's profile and you need to get the Id of the profile you are working on, you can use a ViewBag to capture the Id e. You need to add using statement because GetUserId won't be there without it.
How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. NET Core? Ask Question. Asked 6 years, 7 months ago. Active 10 months ago. Viewed k times. I am using Microsoft. Improve this question. Null 1, 9 9 gold badges 26 26 silver badges 32 32 bronze badges.
MRainzo MRainzo 3, 2 2 gold badges 13 13 silver badges 24 24 bronze badges. Thank you PravinDeshmukh but that returns the name of the user and not the id — MRainzo. It should work. See the samples in asp. Just make sure user is logged in. PravinDeshmukh, never use System. Current in vnext : — Imran Qadir Baksh - Baloch. Hi user, can you please tell us why? PravinDeshmukh because it will not work on.
NET core and there is no System. Web dependency. Add a comment. Active Oldest Votes. Update in ASP. FindFirstValue ClaimTypes. T Convert. Improve this answer. TanvirArjel TanvirArjel But User is returning null in my case? Where am I doing wrong? Are you sure that you are logged in with a user? My scenario is like I want the username of the user logged in my system. Let it be Ubuntu or Windows?
And as I'm testing this in windows I'm logged in under my namee. But it's returning null. Then have to see your code! May be any external agent playing a role here.
I've found that if you've got a null result from User. Name , it could be because Anonymous Authentication is enabled. I was able to get User. If you have a reason to do so, then it is correct, but otherwise, you should probably not use impersonation. Vishwajeet Kulkarni Vishwajeet Kulkarni 11 11 bronze badges. I meant design new log in page.
Which browser you are running your page on? Ogglas Ogglas FindByIdentity context, User. Satish Satish 1. 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. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta.
New post summary designs on greatest hits now, everywhere else eventually. Linked Related As soon as I put in the above code into the webconfig file, it worked on the intranet, it just returned errors in my local, but as soon as I added the above to my local applicationhost. Then, I called the following variable to return the name of the logged in user on windows:. NET first steps setting up a web server.
You may not be getting the values when you run the application from Visual Studio Check it after deployed in IIS. For Value enter the website you're trying to set access on and click OK. Name, WindowsPrincipal this. LogonUserIdentity also got me the Windows username logged in. For reference System. UserName and System. Name, both of these still gave the IIS user. How are we doing?
Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. NET page? Ask Question. Asked 8 years, 8 months ago. Active 3 years, 7 months ago. Viewed 95k times.
0コメント