1

Is there a way to run REST service or SPService in JQuery with Admin. privilege same like RunWithElevatedPrivilege.

In DispForm.aspx there is a button. I want to add logged user who has read access on list to a group1 (having contribute permission on list) on click of button and then user is navigate to start Nintex workflow. Once Nintex workflow starts, I will remove user from group1.

Below REST service able to add user when run in context of admin. but not in context of user having read access on list.

 var vCurrentLoggedUser=$().SPServices.SPGetCurrentUser({fieldName: "UserName",debug: false});
        vCurrentLoggedUser= "domain\\" + vCurrentLoggedUser;
        var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(57)/users";
        $.ajax({
        url: requestUri,
        type: "POST",
        data: JSON.stringify({'__metadata': { 'type': 'SP.User' }, 'LoginName': vCurrentLoggedUser}),
        headers: 
        {
            "accept":"application/json;odata=verbose",
            "content-type": "application/json;odata=verbose",
            "X-RequestDigest":$("#__REQUESTDIGEST").val()
        },
            success: onSuccess,
            error: onError
        });//End of ajax
        function onSuccess(data) 
        {
            alert('User Added');
        }
        function onError(error) 
        {
            alert(JSON.stringify(error));
        }
0

From the Client Object Model itself, there is no way you can elevate permissions during runtime.

By default, all managed code runs under the Windows Identity of the person executing the code or you can change to FBA if the Sharepoint web application supports it.

But in both cases, it depends on the users set permission level. So a trade off is to create a specific user with necessary permissions in Sharepoint . Then you can login as that user using FBA on the client application ,

Solution of your problem

You can do is to use server code to run the elevated privileges work on the server side, then you can call that function using web services .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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