RoleProvider.AddUsersToRoles Method (String[], String[])

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Adds the specified user names to the specified roles for the configured applicationName.

Namespace:   System.Web.Security
Assembly:  System.Web.ApplicationServices (in System.Web.ApplicationServices.dll)

abstract AddUsersToRoles : 
        usernames:string[] *
        roleNames:string[] -> unit

Parameters

usernames
Type: System.String[]

A string array of user names to be added to the specified roles.

roleNames
Type: System.String[]

A string array of the role names to add the specified user names to.

AddUsersToRoles is called by the Roles class to associate the specified users with the specified roles at the data source. Roles are added to the configured ApplicationName.

If any of the specified role names are not found for the configured applicationName, we recommend that your provider throw a ProviderException.

If any of the specified user names are not associated with any of the specified role names for the configured applicationName, we recommend that your provider throw a ProviderException.

If any of the specified user names is null or is an empty string, we recommend that your provider throw an exception.

If any of the specified role names is null or is an empty string, we recommend that your provider throw an exception.

If your data source supports transactions, we recommend that you include each add operation in a transaction and that you roll back the transaction and throw an exception if any add operation fails.

The following code example shows a sample implementation of the AddUsersToRoles method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: