Thread.CurrentPrincipal.Identity.Name

  • Thread starter Thread starter Peter Larsen [CPH]
  • Start date Start date
P

Peter Larsen [CPH]

Hi,

I'm running a website on IIS 7 / Windows Server 2008.

I can't get Thread.CurrentPrincipal.Identity.Name to work on the server, it
doesn't fail, it just return an empty string.
I am also running the same website on an IIS6 on server 2003 without any
problems.

Does it require special permissions tu run CurrentPrincipal on server 2008
or is it an authentication problem on the IIS ?

Thank you in advance.
BR
Peter
 
Hi Peter,

I have a quick test in my side,

protected void Page_Load(object sender, EventArgs e)
{
this.Title = Thread.CurrentPrincipal.Identity.Name;
}

The Thread.CurrentPrincipal.Identity.Name returns the desired user name for
me at Windows Server 2008 and IIS7. Do you configure the web.config to let
your website use Windows authentication?

<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user. -->
<authentication mode="Windows"/>

Best regards,
Colbert Zhou
Microsoft Online Support Team
 
Hi Colbert,

Thanks for your reply.

Is it necessary to put this in web.config or is it possible to enable this
through the IIS7 ??
I am asking because it seems easier to enable it once.

/Peter
 
Hi Colbert,

I already have the authenticate mode set to "Windows" in the web.config.
So i guess it must be a wrong configuration of the IIS - something that
prevent the site to authenticate - but i can't figure out what it is.

/Peter
 
Hi Colbert,

I have found that by enabling "Windows Authentication" in the IIS and
disabling the other choices, it works.
This is how it was configured in the beginning, but i haven't got it to work
until now(?) !
Thanks for your time.

BR
Peter
 
Back
Top