IsInRole with wild cards?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My WinForm application is activating menus based on the user's roles in AD.
I've created the groups to use the same 3 letter abbreviation. Is there a way
to do something like this:

mnuPlanning.Enabled = wp.IsInRole(@"domain\ibb*"); or
mnuPlanning.Enabled = wp.IsInRole(@"domain\ibb%");

I'm using all possible groups in an if statement now, but would like to
consolidate it as much as possible.

Thanks,

_E
 
Esteban404,

With the principal class you are using, no, it isn't possible.

What you should do is consolidate this into a function which will take
the principal, and your wildcard specification, and iterate through all the
known roles, checking to see that they are in at least one of the roles.

Hope this helps.
 
I've just started the MDI forms for the app so I haven't seen it used more
than once or I may have thought to do that. Too easy, so I didn't see it.
D'oh! I'm probably preoccupied with the 70-320 exam I'm taking tomorrow and
the possibility of great-granchild collections in the application. Time for a
break!

Thanks, Nicholas.

_E

Nicholas Paldino said:
Esteban404,

With the principal class you are using, no, it isn't possible.

What you should do is consolidate this into a function which will take
the principal, and your wildcard specification, and iterate through all the
known roles, checking to see that they are in at least one of the roles.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Esteban404 said:
My WinForm application is activating menus based on the user's roles in
AD.
I've created the groups to use the same 3 letter abbreviation. Is there a
way
to do something like this:

mnuPlanning.Enabled = wp.IsInRole(@"domain\ibb*"); or
mnuPlanning.Enabled = wp.IsInRole(@"domain\ibb%");

I'm using all possible groups in an if statement now, but would like to
consolidate it as much as possible.

Thanks,

_E
 
Back
Top