无法通过使用EWS进行模拟来限制对共享日历的访问

时间:2018-09-24 19:41:28

标签: c# exchangewebservices

我们正在使用EWS将CRM与Exchange Online 2010SP2集成在一起。任务之一:为销售人员提供一个带有下一条规则的日历:每个销售人员都可以在Scheduler中查看所有约会,但只能打开和查看自己约会的详细信息(正文)。 CRM会根据某些业务事件进行约会。我们尝试使用模拟和Sensitivity.Private属性。约会使用模拟的用户名进行放置,但是该用户无法通过OWA或Outlook无法打开约会。因此,它作为“主”用户(创建共享日历并且其凭据用于服务连接的用户)的私人约会放置,他可以在Outlook或OWA中打开它。 EWSEditor显示约会的LastModifiedUser-正确的模拟用户名(不是主用户名)。在Fiddler中,我们可以看到对约会放置请求的“成功”响应(在模拟用户下)。在OutlookSpy中,我们可以看到约会PR_SENDER_NAME_W,PR_SENT_REPRESENTING_NAME_W属性显示了“主人”的用户名。我们卡住了。

模拟的用户对该共享日历具有“所有者”权限。

如果模拟无法解决此问题,委托技术可以做到吗?

在此先感谢您的帮助。

static void Main(string[] args)
{
    ExchangeService services = new 
    ExchangeService(ExchangeVersion.Exchange2010_SP2);

    services.Credentials = new WebCredentials("master@exchserver.com", 
        "MasterPwd");
    services.Url = new Uri("https://someserver.com/ews/exchange.asmx");

    FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Calendar);
    FolderView fvFolderView = new FolderView(100);

    DateTime startDate = DateTime.Now.AddDays(1);
    DateTime endDate;

    string SalesCalendarId = "AAMkADVlMGVjZWVkLT....AADo8XAAA=";

    CalendarFolder folder = CalendarFolder.Bind(services, new 
    FolderId(SalesCalendarId));

    TimeSpan ts = new TimeSpan(10, 00, 0);
    startDate = startDate.Date + ts;
    endDate = startDate.AddMinutes(60);

    services.HttpHeaders.Add("X-AnchorMailbox","impersonateduser@exchserver.com");

    appointment.Subject = "from Test";
    appointment.Body = "Test";
    appointment.Start = startDate;
    appointment.End = appointment.Start.AddMinutes(30);
    appointment.ReminderDueBy = appointment.Start.AddHours(1);
    appointment.Sensitivity = Sensitivity.Private;
    ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "impersonateduser@exchserver.com");

    appointment.Save(SalesCalendarId, SendInvitationsMode.SendToNone);
}

1 个答案:

答案 0 :(得分:0)

您可以使用模拟用户来获得“所有者”权限。

请在services.Credentials = new WebCredentials("master@exchserver.com", "MasterPwd")

之前加入以下代码
services.PreAuthenticate = true;

您需要确保根据下面提到的文章,我们具有EWS模拟的必需权限:

Configuring Exchange Impersonation in Exchange 2010

Using Exchange Impersonation in Exchange 2010

您可以参考以下链接:

Get all calendar events for a specific user