Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Pls help me on this.
You are creating an ASP.NET Web site.
The site is configured to use membership and role management providers.
You need to check whether the logged on user is a member of role named administrators.
what to be used here?
1.GetUsersInRole
2.ValidateUsers
3.GetRolesForUsers
4.IsInRole
Posted 3-Jan-13 3:37am
Tejal S1.9K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The typical way of checking whether a user is in a specific role is to use the IsInRole call.
If you have a large organization, methods like GetUsersInRole can take a very long time to execute as there may be thousands of users within the role.
As well, if a user is in many roles, then GetRolesForUsers can take a very long time to execute.
  Permalink  
Comments
Abhinav S at 3-Jan-13 12:23pm
   
5!
Marcus Kramer at 3-Jan-13 13:11pm
   
Thanks.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I have used in my project as given below .hope it will help
if (Roles.IsUserInRole(txtUname.Text.Trim(), "administrators"))
            {
             //coading
            }
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100