TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Robert Turner
NA
7
0
Problem with IsInRole()
Aug 13 2005 1:31 PM
I seem to be having a problem with using IsInRole. if (Page.User.IsInRole("User")) { Response.Write("In group"); } else { Response.Write("Not in group"); } It does not seem to matter what string that I place in the function it always comes as false. I tried this piece of code: AppDomain myDomain = Thread.GetDomain(); myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal; Response.Write("Thread User is: " + myPrincipal.Identity.Name.ToString()); Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole)); foreach (object roleName in wbirFields) { try { Response.Write(roleName + " : " + myPrincipal.IsInRole((WindowsBuiltInRole)roleName)); } catch (Exception) { Response.Write("Could not obtain role for this " + roleName); } } if (myPrincipal.IsInRole("User")) { Response.Write("In group"); } else { Response.Write("Not in group"); } Administrator : True User : True Guest : False PowerUser : False Could not obtain role for AccountOperator Could not obtain role for this SystemOperator Could not obtain role for this PrintOperator BackupOperator : False Could not obtain role for this Replicator Not in group Although the first bit of code said that true for 'User' the second reported false. The problem is that I do not want to check against a Windows built in role for groups that has design for my pupose. Each role will depend if some controls are read only or not. Cheers Robert T Turner
Reply
Answers (
0
)
SymmetricAlgorithm generates erratic results
How to open password protected MS Access Database......