【发布时间】:2020-10-29 12:17:51
【问题描述】:
我有 Azure Function v3,我想通过使用全局管理员帐户凭据来使用 CSOM 和 .NET 标准 2.0 更新 Sharepoint 用户配置文件属性。正在阅读。
var site = new Uri("https://domain-admin.sharepoint.com");
using (var authenticationManager = new AuthenticationManager())
using (var context = authenticationManager.GetContext(site, user, password))
{
var peopleManager = new PeopleManager(context);
var personProperties = peopleManager.GetPropertiesFor(accountName);
context.Load(personProperties, p => p.AccountName, p => p.UserProfileProperties);
await context.ExecuteQueryAsync();
Console.WriteLine(personProperties.UserProfileProperties["FirstName"]); //works
peopleManager.SetSingleValueProfileProperty(personProperties.AccountName, "FirstName", "CSOMvalue");
await context.ExecuteQueryAsync(); //error, access denied
}
确切的错误消息:System.Private.CoreLib:执行函数时出现异常:FunctionName。 Microsoft.SharePoint.Client.Runtime:访问被拒绝。您无权执行此操作或访问此资源。
AuthenticationManager 类取自 here 的 MS 文档 我正在使用 Microsoft.SharePointOnline.CSOM v16.1.20518.12000 nuget 包。
我制作了 .NET Framework 4.7.2 Web 应用程序,它使用 SharePointOnlineCredentials 工作。但我想知道如何让它在 .NET Standard 2.0 上运行。
【问题讨论】:
标签: c# azure-functions sharepoint-online csom .net-standard-2.0