System.Web.Security.Roles.AddUserToRoles Method

Adds the specified user to the specified roles.

Syntax

public static void AddUserToRoles (string username, string[] rolenames)

Parameters

rolenames
Documentation for this section has not yet been entered.
username
The user name to add to the specified roles.

Remarks

The Roles.AddUserToRoles(string, String[]) method calls the default role provider to associate the specified user with the specified roles 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 Roles.AddUserToRoles(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