System.Web.Security.SqlRoleProvider.AddUsersToRoles Method

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

Syntax

public override void AddUsersToRoles (string[] usernames, string[] rolenames)

Parameters

rolenames
Documentation for this section has not yet been entered.
usernames
A string array of user names to be added to the specified roles.

Remarks

The SqlRoleProvider.AddUsersToRoles(String[], String[]) method is called by the System.Web.Security.Roles 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 Roles.AddUserToRole(string, string), Roles.AddUserToRoles(string, String[]), Roles.AddUsersToRole(String[], string), and Roles.AddUsersToRoles(String[], String[]) methods of the System.Web.Security.Roles class.

The database updates that are performed during the call to the SqlRoleProvider.AddUsersToRoles(String[], String[]) 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 System.Web.Security.SqlRoleProvider is being used with the System.Web.Security.SqlMembershipProvider, 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.

Requirements

Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0