Background
I had developed a client solution1 for SharePoint Online
for query certain info from users (i.e: AccountName, PreferredName, Picture, etc) and show the obtained info in a page where the script is referenced.
I already archieve this1, but, after make tests with a read-only user, the script fails because the user has not neccesary permissions.
Requirement
Create script that allows to any user who enter to the site that contains the referenced script, can view the info of users who are in group.
Actual problem
Since the provided solution should be a client solution (i.e scripts), I have to avoid generate server-side solutions based on:
- Since it's SharePoint Online, I could try generate a sandboxed solution, but due to its limitations, custom code for run with elevated priviledges may not be available.
- Honestly, I don't know how for build an App and learn how to build apps requires amount of time that we don't have.
I'm not asking the full code, but instead, a workaround that suits with the described requirement2.
1 Using SharePointPlus and CSOM.
2 I was reading about consume webservices (.asmx) however, after tried this solution, I received that the user has not permissions.
Here is the code that I modified fot this purpose:
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetUserProfileCount xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService' /> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "https://<sitename>/_vti_bin/UserProfileService.asmx?op=GetUserProfileCount",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
function processResult(xData, status) {
console.log(xData);
console.log(xData.responseText);
console.log(status);
}
And here are the results (translated):
Access Denied: Only an administrator can retrieve a count of all users.
Full reponse:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>No se pudo efectuar la operación ---> Acceso denegado: solo un administrador puede recuperar un recuento de todos los usuarios.</faultstring>
<detail>
<ErrorCode xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">UnauthorizedAccess</ErrorCode>
<ErrorMessage xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">Access Denied: Only an administrator can retrieve a count of all users.</ErrorMessage>
</detail>
</soap:Fault>
</soap:Body>
(In Spanish):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>No se pudo efectuar la operación ---> Acceso denegado: solo un administrador puede recuperar un recuento de todos los usuarios.</faultstring>
<detail>
<ErrorCode xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">UnauthorizedAccess</ErrorCode>
<ErrorMessage xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">Acceso denegado: solo un administrador puede recuperar un recuento de todos los usuarios.</ErrorMessage>
</detail>
</soap:Fault>
</soap:Body>