Created
February 27, 2020 11:42
-
-
Save ktskumar/458e1c9d46038078470f3a1d9935fdbe to your computer and use it in GitHub Desktop.
Validate Current User can create Office 365 Group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Modify domain.sharepoint.com with your SharePoint site URL | |
getRequest("https://domain.sharepoint.com/_api/GroupSiteManager/CanUserCreateGroup").then(function(output) { | |
var result = JSON.parse(output.response); | |
if (result.value){ | |
alert("The current User can create Office 365 Group!"); | |
}else{ | |
alert("The current User do not have permission to create Office365 Group!"); | |
} | |
}); | |
//getRequest method reference | |
//https://gist.github.com/ktskumar/a9e9df497673e9fd26ead8532b9ff425 | |
function getRequest(url) { | |
var request = new XMLHttpRequest(); | |
return new Promise(function(resolve, reject) { | |
request.onreadystatechange = function() { | |
if (request.readyState !== 4) return; | |
if (request.status >= 200 && request.status < 300) { | |
resolve(request); | |
} else { | |
reject({ | |
status: request.status, | |
statusText: request.statusText | |
}); | |
} | |
}; | |
request.open('GET', url, true); | |
request.setRequestHeader("Content-Type", "application/json;charset=utf-8"); | |
request.setRequestHeader("ACCEPT", "application/json; odata.metadata=minimal"); | |
request.setRequestHeader("ODATA-VERSION", "4.0"); | |
request.send(); | |
}); | |
} | |
//Author: Shantha Kumar T | |
//Web: https://www.ktskumar.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment