Author: RMcBride | Posted on: 7/31/2009 12:56:00 PM | Views : 562

 Hi all
I am writing a small routine and as a part of that routine I need to test to see if a given user is in a certain role. If the users IS NOT in the role, I need to add the user to the role. If the user IS in the role, I do nothing.
One way to do this might simply be to ALWAYS add the user to the role. If the user is already in the role, then the add "should" fail but that will likely create an error message. A more elegant way would be to use something like Roles.GetRolesForUser("username"), but I haven't done anything like this.
Of course I could always do a SQL lookup in the Roles table to see if there is a row for the user/role, but I would rather use the ASP Membership method.
So, how would I do this using Roles.GetRolesForUser("username")?
Thanks
Richard
...

Go to the complete details ...