Roles::AddUserToRole Method (String^, String^)
.NET Framework (current version)
Adds the specified user to the specified role.
Assembly: System.Web (in System.Web.dll)
Parameters
- username
-
Type:
System::String^
The user name to add to the specified role.
- roleName
-
Type:
System::String^
The role to add the specified user name to.
| Exception | Condition |
|---|---|
| System::ArgumentNullException | roleName is null. -or- username is null. |
| System::ArgumentException | roleName is an empty string or contains a comma (,). -or- username is an empty string or contains a comma (,). |
| System.Configuration.Provider::ProviderException | Role management is not enabled. -or- User is already assigned to the specified role. |
The AddUserToRole method calls the default role provider to associate the specified user with the specified role at the data source.
Note |
|---|
User names and role names cannot contain commas. |
.NET Framework
Available since 2.0
Available since 2.0
Show:
.jpeg?cs-save-lang=1&cs-lang=cpp)