0

I have 2 sites for 2 different groups. One group has access to site1 and one group has site2. Each group does not have access to the others site.

I have a query however that needs to access each site upon entry of a field to see if it exists. Unfortunately the query will fail due to the user not having access to one of the sites.

Is there a way that I can pass credentials that have access to query?

This is my code:

var clientContext = new SP.ClientContext('https://mysite.sharepoint.com/site/site1/');
var oList = clientContext.get_web().get_lists().getByTitle('list');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'Title\'/>' +
    '<Value Type=\'Text\'>'+check+'</Value></Eq></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery); 
clientContext.load(collListItem, 'Include(Id, DisplayName)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

1 Answer 1

0

You can impersonate only using server side code.

So either provide read access or create a custom web part for displaying data.

5
  • Can't give these users read access, how would I go about creating a web part to do that?
    – Tom
    Commented May 5, 2015 at 20:22
  • You need to use Visual Studio. And create a SharePoint project. Then use a visual web part. Drop a GridView control. And use elevated to query data. Commented May 5, 2015 at 20:24
  • Can I use my script to call a C# code to impersonate a user that would have access to both sites?
    – Tom
    Commented May 6, 2015 at 15:02
  • In that case you should deploy that c# code as a web service Commented May 6, 2015 at 15:07
  • How would I call that functionality in the javascript before I run my query?
    – Tom
    Commented May 6, 2015 at 15:35

Your Answer

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

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