如何在Sharepoint Online 2018中为文档创建匿名链接

时间:2018-12-26 12:45:32

标签: sharepoint sharepoint-online sharepoint-2016

我正在尝试为Sharepoint Online 2018中的文档创建匿名链接。

我尝试使用Microsoft.SharePoint.Client提供的CreateAnonymousLink方法,但会引发错误。

ClientResult<string> result = Microsoft.SharePoint.Client.Web.CreateAnonymousLink(clientContext, absoluteurl, false); clientContext.ExecuteQuery();

1 个答案:

答案 0 :(得分:0)

我的样本测试代码供您参考。

using (var context = new ClientContext("https://tenant.sharepoint.com/sites/Developer"))
            {
                Console.ForegroundColor = ConsoleColor.Green;
                string password = "pw";
                SecureString sec_pass = new SecureString();
                Array.ForEach(password.ToArray(), sec_pass.AppendChar);
                sec_pass.MakeReadOnly();
                context.Credentials = new SharePointOnlineCredentials("lee@tenant.onmicrosoft.com", sec_pass);
                ClientResult<string> a = Web.CreateAnonymousLink((ClientRuntimeContext)context, "https://tenant.sharepoint.com/sites/Developer/Shared%20Documents/Culture%20Training.docx", false);

                context.ExecuteQuery();
                Console.WriteLine("done");
                Console.ReadKey();
            }

enter image description here