469,362 Members | 2,603 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

IsInRole problem?

Hi,

I'm testing the IsInRole method on my app. I'm using Integrated security so
I'm not sure if that has something to do with it. I have a groups table
which I want to secure certain portions of my application.

In the global.asax:

protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
string[] arrRoles = new string[]{"Manager", "Cleaner"};
System.Threading.Thread.CurrentPrincipal = new
System.Security.Principal.GenericPrincipal(Context .User.Identity, arrRoles);
}
}

In a page secured by integrated security I get "false" for the following code:

Context.User.IsInRole("Manager") //-returns false when I thought it should
be true?

Thanks

Nov 19 '05 #1
2 3084
I'd really create my own object to keep track of these roles. Attaching to the context works great for a forms-authentication app, but when you throw windows authentication into the mix, by default, IsInRole will be checking active directory groups. You are essentially trying to overwrite this, which to me doesn't seem like a good idea. You'll have a lot more flexibility down the road if you create your own object to check these roles, and just store that in the session.
--Michael

"Dave" <Da**@discussions.microsoft.com> wrote in message news:F1**********************************@microsof t.com...
Hi,

I'm testing the IsInRole method on my app. I'm using Integrated security so
I'm not sure if that has something to do with it. I have a groups table
which I want to secure certain portions of my application.

In the global.asax:

protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
if (Request.IsAuthenticated)
{
string[] arrRoles = new string[]{"Manager", "Cleaner"};
System.Threading.Thread.CurrentPrincipal = new
System.Security.Principal.GenericPrincipal(Context .User.Identity, arrRoles);
}
}

In a page secured by integrated security I get "false" for the following code:

Context.User.IsInRole("Manager") //-returns false when I thought it should
be true?

Thanks




Nov 19 '05 #2
Hi Dave,

Role name like user name should also include domain name:

User.IsInRole("Your_Domain_Name\Manager")

HTH

Elton Wang
el********@hotmail.com

-----Original Message-----
Hi,

I'm testing the IsInRole method on my app. I'm using Integrated security soI'm not sure if that has something to do with it. I have a groups tablewhich I want to secure certain portions of my application.

In the global.asax:

protected void Application_AcquireRequestState(Object sender, EventArgs e){
if (Request.IsAuthenticated)
{
string[] arrRoles = new string[] {"Manager", "Cleaner"}; System.Threading.Thread.CurrentPrincipal = newSystem.Security.Principal.GenericPrincipal (Context.User.Identity, arrRoles); }
}

In a page secured by integrated security I get "false" for the following code:
Context.User.IsInRole("Manager") //-returns false when I thought it shouldbe true?

Thanks

.

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by JIM.H. | last post: by
5 posts views Thread by arjun | last post: by
reply views Thread by Peter | last post: by
8 posts views Thread by Oliver Rainer | last post: by
4 posts views Thread by Bob | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.