Sharepoint 2010 SharePoint 2013匿名访问

Sharepoint 2010 SharePoint 2013匿名访问,sharepoint-2010,sharepoint-2013,csom,Sharepoint 2010,Sharepoint 2013,Csom,如何使用CSOM将匿名访问添加到列表中。在服务器端对象模型中,我可以使用AnonymousPermMask64,但如何使用CSOM实现它呢?如果您可以在SharePoint应用程序中使用它,请尝试这样做 string realm = TokenHelper.GetRealmFromTargetUrl(siteUri); //Get the access token for the URL. //Requires this app to be registered with the tena

如何使用CSOM将匿名访问添加到列表中。在服务器端对象模型中,我可以使用AnonymousPermMask64,但如何使用CSOM实现它呢?

如果您可以在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
}
参考资料:

对于令牌帮助程序: