判断user 是否开启 delve 功能
用Delve功能可以share自己的数据,以及看到别人的数据,这个O365级别的APP能否使用,是由一个叫Office Graph的setting控制的,目前O365管理员只能开启或者关闭整个tenant的Office Graph setting,然后每个user能在SP中的User Profile里开启或者关闭自己的office graph setting
对应的属性为 OfficeGraphEnabled
//Tenant Admin Details
string tenantAdministrationUrl = "https://tenant-admin.sharepoint.com";
string tenantAdminLoginName = "admin@tenant.onmicrosoft.com";
string tenantAdminPassword = "password";
//AccountName of the user whos property you want to update.
//If you want to update properties of multiple users, you can fetch accountnames through search.
string UserAccountName = "i:0#.f|membership|someone@tenant.onmicrosoft.com";
using (ClientContext ctx = new ClientContext(tenantAdministrationUrl))
{
var password = new SecureString();
foreach (char c in tenantAdminPassword) password.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials(tenantAdminLoginName, password);
//Get the people manager instance for tenant context
PeopleManager peopleManager = new PeopleManager(ctx);
var userProfile = peopleManeger.GetPropertiesFor("i:0#.f|membership|someone@tenant.onmicrosoft.com");
ctx.Load(userProfile);
ctx.ExecuteQuery();
//Set true or false to update the setting.
peopleManager.SetSingleValueProfileProperty(UserAccountName, "OfficeGraphEnabled", "True");
ctx.ExecuteQuery();
}
*注意:生成 context 的 url 必须为 tenant administration url 否则会提示没有权限操作其他user 当然可以修改自己的属性