System.Web.Security.Roles.AddUsersToRole Method

Adds the specified users to the specified role.

Syntax

public static void AddUsersToRole (string[] usernames, string rolename)

Parameters

rolename
Documentation for this section has not yet been entered.
usernames
A string array of user names to add to the specified role.

Remarks

The Roles.AddUsersToRole(String[], string) method calls the default role provider to associate the specified users with the specified role at the data source.

If your application uses the System.Web.Security.SqlRoleProvider 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.

Note:

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