System.Web 2.0.0.0 System.Web.Security.RoleProvider

This class is used by the and classes to provide role-management services for an ASP.NET application using a SQL Server database. You can use role management to specify different levels of authorization for your application.

To use the class, you must first create the SQL Server database used by the . To create the database used by the class, run the aspnet_regsql.exe executable found in the C:\WINDOWS\Microsoft.NET\Framework\ folder and specify the -Ar option (for example, aspnet_regsql.exe -Ar). The database created is called Aspnetdb. Alternatively, run aspnet_regsql.exe to pull up the GUI configuration mode and choose to configure all ASP.NET features.

If the role provider is configured with a connection string that uses integrated security, the process account of the ASP.NET application must have rights to connect to the SQL Server database.

The Machine.config file is configured with a instance named AspNetSqlProvider that connects to the SQL Server on the local machine. You can use this instance of the provider, or specify your own in the Web.config file for your ASP.NET application. To use the AspNetSqlProvider instance, specify AspNetSqlProvider as the defaultProvider in your roleManager configuration.

You can configure the to use the same database and user information as the in order to use a single database for authentication and authorization information. To use the same database for membership and role information, run the aspnet_regsql.exe executable and install the membership feature. Then, specify the same connection string in your configuration for both your and instances. Also ensure that both provider instances are configured with the same .

Manages storage of role membership information for an ASP.NET application in a SQL Server database.

- Constructor

  The constructor is called by ASP.NET to create an instance of the class as specified in the configuration for the application. This constructor is not intended to be used from your code.

  Creates an instance of the class.

  2.0.0.0
- Method
  System.Void `` `` To be added.

  The method is called by the class to associate one or more users with one or more roles in the SQL Server database specified in the ASP.NET application's configuration file (Web.config). This method is called by the , , , and methods of the class.

  The database updates that are performed during the call to the method are made within a transaction. If an error is encountered, such as a user name that is already in a specified role, the transaction is rolled back and no updates are performed.

  If the is being used with the , and one of the specified user names does not exist in the database, the user name will be automatically added to the database.

  User names and role names cannot contain commas.

  Adds the specified user names to each of the specified roles.

  A string array of user names to be added to the specified roles. 2.0.0.0
- Property
  System.String To be added.

  The is used by the to associate users and roles with different applications. This enables multiple applications to use the same database to store user and role information without running into conflicts between duplicate user names or role names. Multiple ASP.NET applications can use the same database by specifying the same value in the property. The property can be set programmatically, or it can be set declaratively in the configuration file for the Web application using the applicationName attribute.

  If a value is not specified for the applicationName attribute in the configuration file for the Web application, then the property value for the current object is used.

  Because a single default role provider instance is used for all of the requests served by an object, you can have multiple requests executing concurrently and attempting to set the property value. The property is not thread safe for multiple writes, and changing the property value can result in unexpected behavior for multiple users of an application. It is recommended that you avoid writing code that allows users to set the property unless you must. An example of an application where setting the property may be required is an administrative application that manages role data for multiple applications. Such an application should be a single-user application and not a Web application.

  Gets or sets the name of the application for which to store and retrieve role information.

  2.0.0.0
- Method
  System.Void `` To be added.

  The method is called by the class to create a role in the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  The maximum length for the role name is 256 characters. Role names are not case-sensitive. Commas are not allowed in role names.

  Adds a new role to the role database.

  2.0.0.0
- Method
  System.Boolean `` `` To be added.

  The method is called by the class to delete a role from the SQL Server database specified in the ASP.NET application's configuration file (Web.config). When a role is deleted, the list of users associated with that role is also deleted from the database. The user information in the database is not affected.

  If is true, then an exception will be thrown and the role will not be deleted if the role identified by the parameter has one or more members. If is false, then the role will be deleted whether it is empty or not.

  Removes a role from the role database.

  true if the role was successfully deleted; otherwise, false.

  If true, throws an exception if has one or more members. 2.0.0.0
- Method
  System.String[] `` ``

  The method is called by the class and returns a list of users in a role where the user name contains a match of the supplied for the configured applicationName. The searches for a user name that matches the parameter value using the LIKE keyword and supports SQL Server wildcard characters. For example, if the parameter is set to "user1", then membership information for the user with the user name of "user1" is returned, if it exists. If the parameter is set to "user%", then membership information for users with the user name of "user1", "user2", "user_admin", and so on are returned.

  Gets an array of user names in a role where the user name contains the specified user name to match.

  A string array containing the names of all the users where the user name matches and the user is a member of the specified role.

  The role to search in. The user name to search for. 2.0.0.0
- Method
  System.String[]

  The method is called by the class to retrieve a list of all the roles in the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  Gets a list of all the roles for the application.

  A string array containing the names of all the roles stored in the database for a particular application.

  2.0.0.0
- Method
  System.String[] ``

  The method is called by the class to retrieve a list of a specified user's roles from the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  Gets a list of the roles that a user is in.

  A string array containing the names of all the roles that the specified user is in.

  The user to return a list of roles for. 2.0.0.0
- Method
  System.String[] `` To be added.

  The method is called by the class to retrieve the list of users associated with the specified role in the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  Gets a list of users in the specified role.

  A string array containing the names of all the users who are members of the specified role.

  2.0.0.0
- Method
  System.Void `` ``

  This method initializes the with the property values specified in the ASP.NET application configuration file (Web.config) and is not intended to be used directly from your code.

  Initializes the SQL Server role provider with the property values specified in the ASP.NET application's configuration file. This method is not intended to be used directly from your code.

  The name of the instance to initialize. A that contains the names and values of configuration options for the role provider. 2.0.0.0
- Method
  System.Boolean `` `` To be added.

  The method is called by the class and the method of the property to determine whether a user is associated with a role in the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  Gets a value indicating whether the specified user is in the specified role.

  true if the specified user name is in the specified role; otherwise, false.

  The user name to search for. 2.0.0.0
- Method
  System.Void `` `` To be added.

  The method is called by the class to remove one or more users from one or more roles in the SQL Server database specified in the ASP.NET application's configuration file (Web.config). This method is called by the , , , and methods of the class.

  The database updates that are performed during the call to are made within a transaction. If an error is encountered, such as a user name that does not exist or a user name that is already in a specified role, the transaction is rolled back and no updates are performed.

  User names and role names cannot contain commas.

  Removes the specified user names from the specified roles.

  A string array of user names to be removed from the specified roles. 2.0.0.0
- Method
  System.Boolean `` To be added.

  The method is called by the class to determine whether a role name exists in the SQL Server database specified in the ASP.NET application's configuration file (Web.config).

  Gets a value indicating whether the specified role name already exists in the role database.

  true if the role name already exists in the database; otherwise, false.

  2.0.0.0