2017-02-17 14 views
0

CSOMを使用してリストに匿名アクセスを追加する方法を教えてください。サーバーサイドオブジェクトモデルではAnonymousPermMask64を使用できますが、CSOMを使用して実装する方法は?SharePoint 2013匿名アクセス

答えて

0

SharePointアプリケーションで使用できる場合は、次のようにしてください。

string realm = TokenHelper.GetRealmFromTargetUrl(siteUri); 

//Get the access token for the URL. 
//Requires this app to be registered with the tenant 
string accessToken = TokenHelper.GetAppOnlyAccessToken(
    TokenHelper.SharePointPrincipal, 
    siteUri.Authority, 
    realm).AccessToken; 

//Get client context with access token 
using(var clientContext = TokenHelper.GetClientContextWithAccessToken(
    siteUri.ToString(),accessToken)) 
{ 
    //Do work here 
} 

参考文献:トークンヘルパーについては https://blogs.msdn.microsoft.com/kaevans/2013/10/24/what-every-developer-needs-to-know-about-sharepoint-apps-csom-and-anonymous-publishing-sites/

https://github.com/OfficeDev/SharePoint-Add-in-CSOM-BasicDataOperations/blob/master/SharePoint-Add-in-CSOM-BasicDataOperationsWeb/TokenHelper.cs

関連する問題