asp.net.ph

Roles Class

System.Web.Security Namespace


.NET Framework version 2.0

Manages user membership in roles for authorization checking in an ASP.NET application. This class cannot be inherited.

Roles Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public static ApplicationName String [ Get , Set ]
public static CacheRolesInCookie Boolean [ Get ]
public static CookieName String [ Get ]
public static CookiePath String [ Get ]
public static CookieProtectionValue CookieProtection [ Get ]
public static CookieRequireSSL Boolean [ Get ]
public static CookieSlidingExpiration Boolean [ Get ]
public static CookieTimeout Int32 [ Get ]
public static CreatePersistentCookie Boolean [ Get ]
public static Domain String [ Get ]
public static Enabled Boolean [ Get , Set ]
public static MaxCachedResults Int32 [ Get ]
public static Provider RoleProvider [ Get ]
public static Providers RoleProviderCollection [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public static AddUsersToRole ( String usernames , String roleName ) Void
public static AddUsersToRoles ( String usernames , String roleNames ) Void
public static AddUserToRole ( String username , String roleName ) Void
public static AddUserToRoles ( String username , String roleNames ) Void
public static CreateRole ( String roleName ) Void
public static DeleteCookie ( ) Void
public static DeleteRole ( String roleName ) Boolean
public static DeleteRole ( String roleName , Boolean throwOnPopulatedRole ) Boolean
public static FindUsersInRole ( String roleName , String usernameToMatch ) String
public static GetAllRoles ( ) String
public static GetRolesForUser ( String username ) String
public static GetRolesForUser ( ) String
public static GetUsersInRole ( String roleName ) String
public static IsUserInRole ( String roleName ) Boolean
public static IsUserInRole ( String username , String roleName ) Boolean
public static RemoveUserFromRole ( String username , String roleName ) Void
public static RemoveUserFromRoles ( String username , String roleNames ) Void
public static RemoveUsersFromRole ( String usernames , String roleName ) Void
public static RemoveUsersFromRoles ( String usernames , String roleNames ) Void
public static RoleExists ( String roleName ) Boolean

Remarks

ASP.NET role management enables you to manage authorization for your application based on groups of users, referred to as roles. By assigning users to roles, you can control access to different parts or features of your Web application based on role instead of, or in addition to, specifying authorization based on user name. For example, an employee application might have roles such as Managers, Employees, Directors, and so on, where different privileges are specified for each role.

Users can belong to more than one role. For example, if your site is a discussion forum, some users might be in the role of both Members and Moderators. You might define each role to have different privileges on the site, and a user who is in both roles would then have both sets of privileges.

To enable role management for your ASP.NET application, use the roleManager element of the system.web section in the Web.config file for your application, as shown in the following example.

<configuration>
   <connectionStrings>
      <add name = "SqlServices" connectionString=
         "Data Source=localhost;Initial Catalog=aspnetdb;Integrated Security=SSPI;" />
   </connectionStrings>

   <system.web>
      <authentication mode = "Forms" >
         <forms loginUrl = "login.aspx"
         name = ".ASPXFORMSAUTH" />
      </authentication>

   <roleManager defaultProvider = "SqlProvider" 
      enabled = "true"
      cacheRolesInCookie = "true"
      cookieName = ".ASPROLES"
      cookieTimeout = "30"
      cookiePath = "/"
      cookieRequireSSL = "false"
      cookieSlidingExpiration = "true"
      cookieProtection = "All" >
      <providers>
         <add
            name = "SqlProvider"
            type = "System.Web.Security.SqlRoleProvider"
            connectionStringName = "SqlServices"
            applicationName = "SampleApplication" />
         </providers>
      </roleManager>
   </system.web>
</configuration>
See Also

RoleManagerModule Class   roleManager Section Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph