CurrentPrincipal, WindowsPrincipal

M

Mark

Hello Friend
Please check following Cod

Dim x As System.Security.Principal.WindowsPrincipa

x = System.Threading.Thread.CurrentPrincipa
Response.Writ
(System.Security.Principal.WindowsIdentity.GetCurrent.Auth
nticationType & "<BR>"
Response.Writ
(System.Security.Principal.WindowsIdentity.GetCurrent.Name
& "<BR>"
Response.Write(x.IsInRol
(System.Security.Principal.WindowsBuiltInRole.Administrato
) & "<BR>"
Response.Write(x.IsInRol
(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.AuthenticationType & "<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"

NTL
FUSION-PUNE\validusernam
Tru
Tru
Fals

---
NTL
FUSION-PUNE\validusernam
Tru
Tru
Fals

The result when "Anonymous Access" set in IIS

NTL
FTPUNE0025\IUSR_FTPUNE002
Fals
False***
Fals

---
NTL
FTPUNE0025\IUSR_FTPUNE002
Fals
True***
Fals

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

Regard
Mark
 
Z

zeldadog

-----Original Message-----
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 & said:
Response.Write
(System.Security.Principal.WindowsIdentity.GetCurrent.Name
& said:
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.Administrator
) & said:
Response.Write(x.IsInRole
(System.Security.Principal.WindowsBuiltInRole.User)
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top