SP.RoleDefinitionCollection object
Represents the collection of SP.RoleDefinition objects that define the role definitions that are available for use within the Web site.
Last modified: March 09, 2015
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.RoleDefinitionCollection()
The RoleDefinitionCollection object has the following members.
Constructor
The RoleDefinitionCollection object has the following constructor.
|
Constructor |
Description |
|---|---|
|
This member is reserved for internal use and is not intended to be used directly from your code. |
Methods
The RoleDefinitionCollection object has the following methods.
|
Method |
Description |
|---|---|
|
Adds a new role definition to the collection based on the role definition information. |
|
|
Gets the role definition with the specified ID from the collection. |
|
|
Gets the role definition with the specified name. |
|
|
Gets the role definition with the specified role type. |
|
|
Gets the role definition at the specified index in the collection. |
Properties
The RoleDefinitionCollection object has the following properties.
|
Property |
Description |
|---|---|
|
|
|
|
Gets the role definition at the specified index in the collection. |
The following example creates an input button on an application page that defines a new role and adds it to the role definitions collection.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/ecmascript" language="ecmascript"> var roleDefinitionCollection; var roleDefinition; function runCode() { var clientContext = new SP.ClientContext.get_current(); if (clientContext != undefined && clientContext != null) { var web = clientContext.get_web(); var permissionsManage = new SP.BasePermissions(); permissionsManage.set(SP.PermissionKind.manageUsers); // Specify properties of the role definition. var roleCreationInfo = new SP.RoleDefinitionCreationInformation(); roleCreationInfo.set_basePermissions(permissionsManage); roleCreationInfo.set_description('Role for managing user permissions.'); roleCreationInfo.set_name('Manage User'); roleCreationInfo.set_order(1); // Add to the role definitions collection. this.roleDefinitionCollection = web.get_roleDefinitions(); this.roleDefinition = this.roleDefinitionCollection.add(roleCreationInfo); clientContext.load(roleDefinition); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } } function onQuerySucceeded() { alert('Created role: ' + this.roleDefinition.get_name()); } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } </script> <input id="Button1" type="button" value="Run Code" onclick="runCode()" /> </asp:Content>
See RoleDefinitionCollection resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/roledefinitions