469,338 Members | 8,161 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

CurrentPrincipal, WindowsPrincipal

Hello Friends
Please check following Code

Dim x As System.Security.Principal.WindowsPrincipal

x = System.Threading.Thread.CurrentPrincipal
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurr ent.Authe
nticationType & "<BR>")
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurr ent.Name
& "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.Admi nistrator
) & "<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.GetCurr ent)
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurr ent.Authe
nticationType & "<BR>")
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurr ent.Name
& "<BR>")
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.Admi nistrator
) & "<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
Nov 18 '05 #1
0 1802

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kevin Burton | last post: by
1 post views Thread by Johan Johansson (Sweden) | last post: by
reply views Thread by wk6pack | last post: by
reply views Thread by =?Utf-8?B?RHVuZTg4?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.