Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CurrentPrincipal, WindowsPrincipal

Reply
Thread Tools

CurrentPrincipal, WindowsPrincipal

 
 
Mark
Guest
Posts: n/a
 
      01-12-2004
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
 
Reply With Quote
 
 
 
 
qvo178 qvo178 is offline
Junior Member
Join Date: Aug 2008
Posts: 29
 
      02-23-2010
Thanks this has help me.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
isinrole reverts to windowsprincipal? Vic ASP .Net Security 0 11-26-2004 09:14 PM
WindowsPrincipal.IsInRole() problem with non-builtin roles naijacoder naijacoder ASP .Net Security 4 09-02-2004 01:56 AM
CurrentPrincipal, WindowsPrincipal Mark ASP .Net Security 1 01-12-2004 01:35 PM
WindowsPrincipal and WindowsIdentity. Kevin Burton ASP .Net 1 01-08-2004 01:20 AM
Role empty in WindowsPrincipal Peter Moberg ASP .Net Security 0 07-25-2003 05:00 AM



Advertisments