判断user 是否开启 delve 功能

判断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 当然可以修改自己的属性


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值