CurrentPrincipal, WindowsPrincipal

M

Mark

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top