Accessing other user calendar using service accoun

2019-06-08 19:28发布

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

2条回答
狗以群分
2楼-- · 2019-06-08 19:49

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

Sample:

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");

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

查看更多
叼着烟拽天下
3楼-- · 2019-06-08 19:50
登录 后发表回答