Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting Europe – Converting REST Call to SharePoint JSOM Object (ECMAScript)
This short article tries to clarify how we utilize REST Call and proselyte to convert to Sharepoint 2013 JSOM Object that recovers the permissions connected with a Role, this can be likewise be utilized for administration of authorizations of things. I made a REST Call that retrieves the Permissions connected with a Sharepoint RoleDefinition.
To get the Sharepoint RoleDefinition related utilizing REST can be utilize the following url: “https://[site]/sites/Dev/_api/Web/RoleDefinitions”
I use the SharePoint RoleDefinition associated to “Full Control” and get the Permissions associated.
Method to call REST Call with Json (SP.BasePermissions)
The example code below, uses SharePoint REST Calls to get the properties of RoleDefinition “Full Control” that includes a Object (SP.BasePermissions) in Json data.
1 2 3 4 5 6 7 8 9 10 11 |
$.ajax({ url: "https://[site]/sites/Dev/_api/Web/RoleDefinitions(1073741829)", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { GetRights(data.d.BasePermissions); }, error: function (xhr) { SP.UI.Notify.addNotification(xhr.status + ': ' + xhr.statusText, false); } }); |
The REST call & returning JSON data can be visible with Fiddler tool as shown as the following picture:
Method to convert REST json data to SharePoint JSOM (SP.BasePermissions)
The Method “GetRights(data)” uses the Json data to include in SP.BasePermissions() Object using Method “fromJson()”.
After the Object made, it will list the Permissions “SP.PermissionKind” and validate if the permissions are associated with Role “Full Control” using the Method “has”.
And here is the Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function GetRights(rights) { var ValidateRights = new SP.BasePermissions(); var permissionsid = ''; var permissionsnames = ''; ValidateRights.fromJson(rights); for (var prop in SP.PermissionKind.prototype) { permissionsid += prop + "\n"; if (ValidateRights.has(parseInt(SP.PermissionKind.prototype[prop]))) { permissionsnames += prop + "\n"; } } alert(permissionsid); alert(permissionsnames); } |
All the permissions are collected in a String and display in the alert message.
The List of Permissions will be Listed using the SP.PermissionKind Object.
Note: fullMask permision does not get all the permissions but only permissions lower then “Low=65535″ in 32 Binary and High=”32767” in 64 Binary from the SP.PermissionKind.prototype array list.
1 2 3 4 |
Low(32): 65: 0000065535: 0000000000000001111111111111111: FullMask High(64): 65: 0000032767: 0000000000000000111111111111111: FullMask |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options
Print article | This entry was posted by Peter on January 21, 2015 at 4:40 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |