473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 1937

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pradeep | last post by:
All, If i set the Thread.CurrentPrincipal am i setting the Principal or on AppDomain? Could someone explain how these calls are different? If i want to store and hand over user information from...
0
by: Alek Davis | last post by:
Hello, I noticed an interesting problem. When calling WindowsPrincipal.IsInRole over dial-up (VPN), this function takes 1-2 minute(s) to return. On the intranet or when disconnected from the...
0
by: Dan Kelley | last post by:
I receive multiple (handled) ArgumentExceptions when I call WindowsPrinciple.IsInRole. The exception text is: A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll...
3
by: Kevin Burton | last post by:
This is more of a solution that raised a question. I have a Web service that does not allow anonymous users. For debugging I put in the following lines in my Web Service: WindowsIdentity wi =...
1
by: Johan Johansson (Sweden) | last post by:
I am writing a webService that is going to be accessed anonymously (I don't want to "configurable" depend on windows integrated authentication). But I still want to authenticate the client (or...
0
by: wk6pack | last post by:
Hi, I'm trying to get my application to authenticate using role based when the user runs the application. When the user logs on and is in the security group "school", the user gets into the...
1
by: =?Utf-8?B?RjVGNUY1?= | last post by:
I use the following function to ascertain if the current user is in ann AD security group. It appears to work, except if the group contains any space characters, it always returns false. For...
1
by: Andy | last post by:
Hi, I currently have my application setup and built using Windows Authentication (WindowsPrincipal). For security checks, I simply do an IsInRole call on the Principal. The role permissions...
0
by: =?Utf-8?B?RHVuZTg4?= | last post by:
Hi there, We're using windows authentication in our web app and calling "thread.currentprincipal.identity.name" to get the currently logged on user name. On our system, the "pre-Windows 2000"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.