Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CurrentPrincipal, WindowsPrincipal

0 views
Skip to first unread message

Mark

unread,
Jan 12, 2004, 2:18:18 AM1/12/04
to
Hello Friends
Please check following Code

Dim x As System.Security.Principal.WindowsPrincipal

x = System.Threading.Thread.CurrentPrincipal
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurrent.Authe
nticationType & "<BR>")
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurrent.Name
& "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.Administrator
) & "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.User)
& "<BR>")
Response.Write(x.IsInRole("MyDomain\MyGroup")
& "<BR>")

Response.Write("<BR>----<BR>")

x = New System.Security.Principal.WindowsPrincipal
(System.Security.Principal.WindowsIdentity.GetCurrent)
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurrent.Authe
nticationType & "<BR>")
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurrent.Name
& "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.Administrator
) & "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.User)
& "<BR>")
Response.Write(x.IsInRole("MyDomain\MyGroup")
& "<BR>")

The result using Basic Windows Authentication, and looged
in with a valid user name "validusername".


NTLM
FUSION-PUNE\validusername
True
True
False

----
NTLM
FUSION-PUNE\validusername
True
True
False

The result when "Anonymous Access" set in IIS.

NTLM
FTPUNE0025\IUSR_FTPUNE0025
False
False**********
False

----
NTLM
FTPUNE0025\IUSR_FTPUNE0025
False
True****
False

**** Why there is a difference for same user.

Regards
Mark

0 new messages