This is a migrated thread and some comments may be shown as answers.

How to get Windows Logged on username

3 Answers 1609 Views
Getting started with ASP.NET
This is a migrated thread and some comments may be shown as answers.
Ratnaker Pingili
Top achievements
Rank 1
Ratnaker Pingili asked on 30 Jul 2009, 09:57 PM
I am trying to get the windows logged on user name inside the user control using ASP.NET and C#. I am using (System.Web.HttpContext.Current.User.Identity.Name) to get the current  windows logged on username. It is giving NETWORK SERVICE as the username instead of current logged in username. After some research i have changed the sitefinity web.config. I have changed authentication mode to windows and now i am getting current logged on username. But, the sitefinity admin site is not working and everything else is working fine.
getting error message when accessing admin site

Server Error in '/' Application.

This type of page is not served.

Description: The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.aspx' may be incorrect.   Please review the URL below and make sure that it is spelled correctly.

Requested URL: /sitefinity/admin/default.aspx


Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082


Please post if you have any ideas how to get current logged on username without changing the authentication mode to windows or post how to recover the sitefinity admin site.

Thanks in advance..........

3 Answers, 1 is accepted

Sort by
0
Ivan Dimitrov
Telerik team
answered on 31 Jul 2009, 01:15 PM
Hello Ratnaker Pingili,

Try using the code below in your user control.

 string username = WindowsIdentity.GetCurrent().Name

In this case you do not have to change authentication mode.

Kind regards,
Ivan Dimitrov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ratnaker Pingili
Top achievements
Rank 1
answered on 31 Jul 2009, 02:31 PM
Hi Ivan,

I have changed the authentication mode to Forms and used string username = WindowsIdentity.GetCurrent().Name to get the logged on user name, again i am getting NT AUTHORITY\NETWORK SERVICE as the current logged on username instead of actual logged on username.
If i change the authentication mode to forms then i am getting an access to sitefinity admin site and getting problem accessing the current logged on username.

Any other solution for this problem.

Thanks,
Ratna
0
Dido
Telerik team
answered on 04 Aug 2009, 07:34 AM
Hello Ratnaker Pingili,

Is Active Directory an option for you? You can see a discussion about it on the ASP.NET forums.

Sincerely yours,
Dido
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
Getting started with ASP.NET
Asked by
Ratnaker Pingili
Top achievements
Rank 1
Answers by
Ivan Dimitrov
Telerik team
Ratnaker Pingili
Top achievements
Rank 1
Dido
Telerik team
Share this question
or