2

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 ---&gt; 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 ---&gt; 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>

2
  • A normal user isn't going to get to enumerate the entire user profile database to pull a count, they are only going to get their profile, and you won't be able to impersonate that client side. You'll likely have to evaluate if this particular piece of the solution is necessary. Feb 16, 2016 at 20:34
  • @EricAlexander, you're right, I'm actually making some tests with SPServices and at the same time (with no results, actually), I'm trying to use server code "I hope that I can solve this problem". I also make a new issue SharePointPlus's GitHub. With the "count" functionality I was hoping later get the users using GetUserProfileByIndex service. Feb 16, 2016 at 22:44

1 Answer 1

1

Have you tried Marc Anderson's SPServices ( http://spservices.codeplex.com ) and / or zplume's JS libraries ( https://gist.github.com/zplume ). They're both fairly extensive.

1
  • 1
    I haven't tried I though that SPServices was commercial but I will try and I post the results. Thanks. Feb 16, 2016 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.