Hi, I have an asp.net application which is able to authenticate against Windows active directory. That part works fine. When a certain user logs in, I want him to be able to check if another user is in a certain role/group.
I tried using Role.IsUserInRole(String username, String rolename) but the application throws an error saying that the current user can only check if the current user is in a role/group. If that is so, then would be the point of the first parameter of this
method if the only user that can be checked is only the current user? So it looks like the first parameter will always need to be "User.Identity.Name".
Is there an easy way for the current user to check if another user is a member of a role/group? If it isn't a simple task, can you point me in the right direction, since I haven't really done this before. Thanks in advance.
S2kDriver
Member
23 Points
156 Posts
How to check roles/groups of other users (not current user) ?
Jan 09, 2013 06:16 PM|LINK
Hi, I have an asp.net application which is able to authenticate against Windows active directory. That part works fine. When a certain user logs in, I want him to be able to check if another user is in a certain role/group.
I tried using Role.IsUserInRole(String username, String rolename) but the application throws an error saying that the current user can only check if the current user is in a role/group. If that is so, then would be the point of the first parameter of this method if the only user that can be checked is only the current user? So it looks like the first parameter will always need to be "User.Identity.Name".
Is there an easy way for the current user to check if another user is a member of a role/group? If it isn't a simple task, can you point me in the right direction, since I haven't really done this before. Thanks in advance.
Angie xu - M...
All-Star
18664 Points
1590 Posts
Microsoft
Re: How to check roles/groups of other users (not current user) ?
Jan 15, 2013 08:09 AM|LINK
Hi S2kDriver
I think Roles.IsUserInRole Method (String, String) method and WebSecurity.UserExists( ) method are available for you,
if ((WebSecurity.UserExists( ) ) && (Roles.IsUserInRole(String username, String rolename)))
You could also refer the usage of Roles.IsUserInRole Method (String, String) method and WebSecurity.UserExists( ) method below,
Roles.IsUserInRole Method (String, String)
WebSecurity.UserExists Method
hope it helps you,
Kind regards
Feedback to us
Develop and promote your apps in Windows Store