>Khan Imran wrote:
"Carl Prothman [MVP]" <ca****@spamcop.net> wrote in message
System.Security.Principal.WindowsIdentity.GetCurre nt().Name;
This Should be easier
string loginid=User.Identity.Name;
Sure it's easier to type in, but watch out, depending on the IIS / web.config file settings,
User.Identity.Name will not give you the correct result (for Windows authentication mode)
On a Windows Server 2003 box where I'm logged in as Administrator:
- With Identity Impersonate= false and IIS Anonymous Access enabled / NTLM enabled
=> WindowsIdentity.GetCurrent().Name = "NT AUTHORITY\NETWORK SERVICE"
=> User.Identity.Name = ""
- With Identity Impersonate= false and IIS Anonymous Access disabled / NTLM enabled
=> WindowsIdentity.GetCurrent().Name = "NT AUTHORITY\NETWORK SERVICE"
=> User.Identity.Name = "CARL20\Administrator"
- With Identity Impersonate= true and IIS Anonymous Access enabled / NTLM enabled
=> WindowsIdentity.GetCurrent().Name = "CARL20\IUSR_CARL20"
=> User.Identity.Name = ""
- With Identity Impersonate= true and IIS Anonymous Access disabled / NTLM enabled
=> WindowsIdentity.GetCurrent().Name = "CARL20\Administrator"
=> User.Identity.Name = "CARL20\Administrator"
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
Hire top-notch developers at
http://www.able-consulting.com