使用服务帐户访问其他用户日历 [英] Accessing other user calendar using service account

查看:91
本文介绍了使用服务帐户访问其他用户日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用EWS托管API集成Office 365.我们已经使用Office 365管理中心创建了一个具有模拟角色的服务帐户. 现在,我们如何使用该服务帐户访问应用程序中其他用户的数据(如邮件,联系人,日历)? 谢谢,罗希特(Rohit)

We are trying to integrate office 365 using EWS managed API's. We have created one service account with impersonation role using office 365 admin center. Now, how can we use that service account to access other user's data(like mails, contacts, calendar) in the application ? Thanks, Rohit

推荐答案

您照常创建ExchangeService的实例,然后设置其ImpersonatedUserId.

You create an instance of ExchangeService as usual and then set its ImpersonatedUserId.

示例:

var credentials = new WebCredentials(
    "impersonateduser@your.onmicrosoft.com", "password", "");

var exchange = new ExchangeService{PreAuthenticate=true, Credentials=credentials};
exchange.ImpersonatedUserId = new ImpersonatedUserId(
    ConnectingIdType.SmtpAddress, 
    "calendaruser@your.onmicrosoft.com");

此后,您可以访问其他用户(在本例中为calendaruser)的数据.

After this you can access the other user's (in this case calendaruser) data.

这篇关于使用服务帐户访问其他用户日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆