How to get Windows Logged on username

4 posts, 0 answers
  1. Ratnaker Pingili
    Ratnaker Pingili avatar
    2 posts
    Member since:
    Jul 2009

    Posted 30 Jul 2009 Link to this post

    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

    This type of page is not served.

    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..........
  2. Ivan Dimitrov
    Admin
    Ivan Dimitrov avatar
    78 posts

    Posted 31 Jul 2009 Link to this post

    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.
  3. Ratnaker Pingili
    Ratnaker Pingili avatar
    2 posts
    Member since:
    Jul 2009

    Posted 31 Jul 2009 Link to this post

    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
  4. Dido
    Admin
    Dido avatar
    1 posts

    Posted 04 Aug 2009 Link to this post

    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.
Back to Top