Adds the specified user to the specified role.

Namespace: Novalys.VisualGuard.Security.Membership
Assembly: Novalys.VisualGuard.Security (in Novalys.VisualGuard.Security.dll) Version: 2016.0.105.16 (2016.0.105.16)

Syntax

C#
[ObsoleteAttribute("Use AddUsersToRoles(ICollection<VGMembershipUser> users, ICollection<VGRole> roles)")]
public void AddUserToRole(
	NTAccount account,
	string roleName,
	Guid applicationId
)
Visual Basic
<ObsoleteAttribute("Use AddUsersToRoles(ICollection<VGMembershipUser> users, ICollection<VGRole> roles)")> 
Public Sub AddUserToRole ( 
	account As NTAccount,
	roleName As String,
	applicationId As Guid
)

Parameters

account
Type: System.Security.Principal..::..NTAccount
The Windows account to add to the specified role.
roleName
Type: System..::..String
The role to add the specified user name to.
applicationId
Type: System..::..Guid
The code of the application where you can find the specified roles.

Exceptions

ExceptionCondition
System..::..ArgumentExceptionroleName is an empty string or is longer than 64 characters or contains invalid chars ('\', '/', '?', '*', '%', ';', ''', '"', ':', '|', '[', ']', '+', '=', ',').

-or-

applicationId was not found in the repository.

-or-

account cannot be converted to SID.
System..::..ArgumentNullExceptionroleName is null.

-or-

account is null.

-or-

applicationId is null.
System.Security..::..SecurityExceptionThe current user has not enough privileges to use Membership API. The Membership access level of the application must be sufficient to allows this action or the 'Membership Manager' role must be granted to the user by using the Visual Guard console.

See Also