3

I have simple webapp , which need to get the current logged on user name of the system.

I tried with :

  Label1.Text = HttpContext.Current.User.Identity.Name.ToString(); 

But this was blank as Anonymous User access was checked. When I unchecked Anonymous user Access then I am unable to browse the web site with error

You are not authorized to view this page

I am using windows authentication in web.config

<authentication mode="Windows"/>

Simsons
  • 12,295
  • 42
  • 153
  • 269

1 Answers1

0

When you use the Windows auth, and disable the Anonymous access, you must provide the Windows user information to your webapp.

Use <identity impersonate="true"/> for this.

VMAtm
  • 27,943
  • 17
  • 79
  • 125
  • @sehe It is false by default. And @Subhen use the windows auth, so we need to push info about user to the web site. – VMAtm Jul 07 '11 at 08:05
  • @sehe This is not about access to the files. This is about the way to auth user. – VMAtm Jul 07 '11 at 08:36
  • Whatever; I was assuming from the (incomplete) information that the OP knows Windows Integrated Auth; I'm just trying to help, not correct you – sehe Jul 07 '11 at 08:37
  • This page is displayed because of anonimous user is disabled, and impersonation (with getting the user from windows) is off. First thing to check - is user impersonated or not. – VMAtm Jul 07 '11 at 08:38
  • @VMAtm, after making impersonation true still I am not able to access it. Updated the question for details – Simsons Jul 07 '11 at 09:01
  • 1
    @Subhen: What browser are you using? Only IE supports this. It also requires your work station to be part of the same domain as the server. – Andy Jul 07 '11 at 14:48