我正在使用以下代码从日历中返回项目。当我连接用户的实际凭据时,我会按预期返回10个项目。当我作为服务帐户连接时,我总是得到0.服务帐户具有查看和更新用户日历的权限。为什么不回复任何结果?
// Connect to Exchange Web Services
service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
--> service.Credentials = new WebCredentials("svc_user", "svc_password", "domain");
--> //service.Credentials = new WebCredentials("user", "password", "domain");
service.AutodiscoverUrl("user@domain");
//Return count
ItemView view = new ItemView(10);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, view);
MessageBox.Show(findResults.Count().ToString());
答案 0 :(得分:0)
我必须为服务提供ImpersonatedUserId
的价值:
// Connect to Exchange Web Services
service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.Credentials = new WebCredentials("svc_user", "svc_password", "domain");
service.AutodiscoverUrl("user@domain");
service.ImpersonatedUserId = new ImpersonatedUserID(ConnectingIdType.SmtpAddres, "user@domain");
//Return count
ItemView view = new ItemView(10);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, view);
MessageBox.Show(findResults.Count().ToString());
我的假设是,通过在用户的商店上运行自动发现,默认情况下会进行模拟。