如何从EWS检索公共日历? [英] How to retrieve public calendars from EWS?

查看:171
本文介绍了如何从EWS检索公共日历?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在通过交易所管理我们的车位预订.每辆汽车都有一个压光机,您可以在该压光机上插入一个约会,以方便使用.

We are managing the reservations for our car pool via exchange. Every car has a calender on which you can insert an appointment with the car, for when you want to use it.

我的任务是取回每辆汽车的压光机和其中的所有约会,但是我仍然坚持如何通过EWS进行正确的呼叫.

My task is to retrieve every car's calender and every appointment in it, but I am stuck on how to make the right call via EWS.

我的步骤如下:

  • 创建Exchange服务
  • 使用服务帐户的凭据
  • AutodiscoverUrl()
  • 创建CalenderFolder,CalenderView并检索约会.
  • ?
  • Create an Exchange service
  • Use credentials of service account
  • AutodiscoverUrl()
  • Create CalenderFolder, CalenderView und retrieve appointments.
  • ?

现在我的问题出在检索约会"上,因为我只能使用其WellKnownFolders访问自己的日历.

Right now my problem is located at "retrieve appointments" because I can only access my own calender with its WellKnownFolders.

我如何访问别人的公共日历并检索他们的约会?

How can I access someone else public calanders and retrieve their appointments?

这是到目前为止我正在使用的代码:(从

This is the code I am working with so far: (gathered from http://msdn.microsoft.com/en-us/library/office/dn439786(v=exchg.80).aspx)

ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.Credentials = new WebCredentials(@"domain\svc_account", @"Dummypassword");
service.UseDefaultCredentials = false;
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.AutodiscoverUrl(@"svc_account@domain.com", RedirectionUrlValidationCallback);

DateTime startTime = DateTime.Now;
DateTime endTime = DateTime.Now.AddDays(10);
int num_appts = 10;

CalendarFolder calFolder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
CalendarView calView = new CalendarView(startTime, endTime, 10);
calView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);

FindItemsResults<Appointment> appointments = calFolder.FindAppointments(calView);

foreach (Appointment a in appointments)
{
    //Do stuff later on...
}

再次:这非常适合我的日历中的约会.我找不到MSDN中有关如何访问其他人数据的部分.

Again: This works well for appointments in my calender. I can't find the parts in the MSDN on how to access someone else data.

推荐答案

看看您可以让特定的用户帐户模拟其他用户帐户并访问其详细信息,而无需其用户名和密码.这也应该适用于资源日历.

You can have a specific user account impersonate another user account and access their details without the need for their username and password. This should work on resource calendars as well.

string impName = @"impy";
string impPassword = @"password";
string impDomain = @"domain";
string impEmail = @"impy@domain.com";

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Credentials = new NetworkCredential(impName, impPassword, impDomain);
service.AutodiscoverUrl(impEmail);

// This will work as if you are that car.
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, @"CAR1@domain.com");

更多参考资料: http://msdn.microsoft.com/zh-我们/library/dd633680(v=exchg.80).aspx

这篇关于如何从EWS检索公共日历?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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