AddUserToRole
Assigns a user to a specified role in SharePoint. Useful for controlling access levels within the site.
Stored Procedure-Specific Information
The AddUserToRole stored procedure adds one or more users to a SharePoint role (permission level). The LoginName parameter accepts a comma-separated list of user login names, and the Role parameter specifies the role name.To add a single user to a role, enter:
EXEC AddUserToRole LoginName = 'DOMAIN\username', Role = 'Custom Role';
To add multiple users to a role, enter:
EXEC AddUserToRole LoginName = 'DOMAIN\user1,DOMAIN\user2', Role = 'Custom Role';
Input
| Name | Type | Required | Description |
| LoginName | String | True | A comma-separated list of login names of the users to be assigned a role. Use the format 'DOMAIN\\username' for Active Directory users or email addresses for Azure AD users. Example: 'Domain\\user1,Domain\\user2'. |
| Role | String | True | The name of the SharePoint role (permission level) to assign to the specified users. Examples include 'Full Control', 'Edit', 'Read'. |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Indicates whether the operation to assign the role was successful. Returns 'true' for success and 'false' for failure. |