当我尝试删除由我创建的日历事件时,Exchange Web服务(EWS)说“已接受拒绝”

时间:2015-10-05 09:25:18

标签: exchange-server exchangewebservices

我正在尝试删除我之前创建的日历事件。

案例1:

  • 我打电话给EWS使用域用户brooms@infusion.com的凭据创建一个日历活动,在一些房间提供房间的电子邮件地址,然后我获得活动的ID
  • 然后我通过调用EWS并提供Id和ChangeKey删除事件,一切都很好 - 会议被删除

案例2

  • 我以与案例1相同的方式创建活动
  • 我获得了这个房间的日历活动列表。现在,事件的ID具有HexEntryId格式。所以我使用ConvertId方法将其转换为DeleteItem方法
  • 所需的EwsLegacyId
  • 我用ConvertId方法提供的事件ID调用DeleteItem方法,但没有ChangeKey(我没有)
  • DeleteItemResponse说“拒绝访问。请检查凭据,然后重试。”

为什么我可以在案例1中删除事件而在案例2中我不能删除?如何删除事件(如案例2)?

以下是请求和回复的详细信息:

Case 1:

I call EWS to create a calendar event using credentials of domain user broom@mycompany.com in some room by providing email address of the room – a meeting like this:
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">
      <soap:Body>
            <CreateItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\"  SendMeetingInvitations=\"SendToAllAndSaveCopy\" >
                  <SavedItemFolderId>
                        <t:DistinguishedFolderId Id=\"calendar\"/>
                  </SavedItemFolderId>
                  <Items>
                        <t:CalendarItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/types\">
                              <Subject>Instant Meeting</Subject>
                              <Body BodyType=\"Text\">Generated By mycompany Room Booker</Body>
                              <ReminderIsSet>false</ReminderIsSet>
                              <ReminderMinutesBeforeStart>60</ReminderMinutesBeforeStart>
                              <Start>2015-10-01T10:26:02.000Z</Start>
                              <End>2015-10-01T10:41:02.000Z</End>
                              <IsAllDayEvent>false</IsAllDayEvent>
                              <LegacyFreeBusyStatus>Busy</LegacyFreeBusyStatus>
                              <RequiredAttendees>
                                    <Attendee>
                                          <Mailbox>
                                                <EmailAddress>brdmlt-mainbrd@mycompany.com</EmailAddress>
                                          </Mailbox>
                                    </Attendee>
                              </RequiredAttendees>
                        </t:CalendarItem>
                  </Items>
            </CreateItem>
      </soap:Body>
</soap:Envelope> 

then meeting is accepted and I get ItemID like:

state.ChangeKey: "DwAAABYAAADw3LMNr7pMRqtEFFAbr0MeAAAAhxz0"        
state.Id: "AAASAGJyb29tQGluZnVzaW9uLmNvbQBGAAAAAAB5mlhabHe9S4yVHCob9IbcBwDw3LMNr7pMRqtEFFAbr0MeAAAAOdnlAADw3LMNr7pMRqtEFFAbr0MeAAAAhrdWAAA="                

Then I delete the event by calling EWS and providing Id and ChangeKey:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
      <soap:Header/>
      <soap:Body>
            <m:DeleteItem DeleteType=\"MoveToDeletedItems\" SendMeetingCancellations=\"SendToAllAndSaveCopy\">
                  <m:ItemIds>
                        <t:ItemId Id=\"AAASAGJyb29tQGluZnVzaW9uLmNvbQBGAAAAAAB5mlhabHe9S4yVHCob9IbcBwDw3LMNr7pMRqtEFFAbr0MeAAAAOdnlAADw3LMNr7pMRqtEFFAbr0MeAAAAhrdWAAA=\" ChangeKey=\"DwAAABYAAADw3LMNr7pMRqtEFFAbr0MeAAAAhxz0\"/>
                  </m:ItemIds>
            </m:DeleteItem>
      </soap:Body>
</soap:Envelope>

and all is fine. The event is deleted.

Case 2:

But when I create event the same way and get response like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="235" MinorBuildNumber="1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:CreateItemResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Items>
            <t:CalendarItem>
              <t:ItemId Id="AAASAGJyb29tQGluZnVzaW9uLmNvbQBGAAAAAAB5mlhabHe9S4yVHCob9IbcBwDw3LMNr7pMRqtEFFAbr0MeAAAAOdnlAADw3LMNr7pMRqtEFFAbr0MeAAAAhrdYAAA=" ChangeKey="DwAAABYAAADw3LMNr7pMRqtEFFAbr0MeAAAAhx08" />
            </t:CalendarItem>
          </m:Items>
        </m:CreateItemResponseMessage>
      </m:ResponseMessages>
    </m:CreateItemResponse>
  </s:Body>
</s:Envelope>

and when I list calendar events for this room like below:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
            <t:RequestServerVersion Version="Exchange2010_SP2" />
      </soap:Header>
      <soap:Body>
            <GetUserAvailabilityRequest xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
                  <TimeZone xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
                        <Bias>300</Bias>
                        <StandardTime>
                              <Bias>0</Bias>
                              <Time>02:0:00</Time>
                              <DayOrder>1</DayOrder>
                              <Month>10</Month>
                              <DayOfWeek>Sunday</DayOfWeek>
                        </StandardTime>
                        <DaylightTime>
                              <Bias>-60</Bias>
                              <Time>02:00:00</Time>
                              <DayOrder>2</DayOrder>
                              <Month>3</Month>
                              <DayOfWeek>Sunday</DayOfWeek>
                        </DaylightTime>
                  </TimeZone>
                  <MailboxDataArray>
                        <MailboxData xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
                              <Email>
                                    <Name/>
                                    <Address>BRDHOU-MAINBRD@mycompany.com</Address>
                                    <RoutingType>SMTP</RoutingType>
                              </Email>
                              <AttendeeType>Room</AttendeeType>
                              <ExcludeConflicts>false</ExcludeConflicts>
                        </MailboxData>
                  </MailboxDataArray>
                  <FreeBusyViewOptions xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
                        <TimeWindow>
                              <StartTime>2015-10-01T06:34:09</StartTime>
                              <EndTime>2015-10-01T23:59:59</EndTime>
                        </TimeWindow>
                        <MergedFreeBusyIntervalInMinutes>60</MergedFreeBusyIntervalInMinutes>
                        <RequestedView>Detailed</RequestedView>
                  </FreeBusyViewOptions>
            </GetUserAvailabilityRequest>
      </soap:Body>
</soap:Envelope>

I get response with IDs in some other format (HexEntryId):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
  <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="235" MinorBuildNumber="1" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <GetUserAvailabilityResponse xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
    <FreeBusyResponseArray>
      <FreeBusyResponse>
        <ResponseMessage ResponseClass="Success">
          <ResponseCode>NoError</ResponseCode>
        </ResponseMessage>
        <FreeBusyView>
          <FreeBusyViewType xmlns="http://schemas.microsoft.com/exchange/services/2006/types">Detailed</FreeBusyViewType>
          <CalendarEventArray xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
            <CalendarEvent>
              <StartTime>2015-10-01T06:36:51</StartTime>
              <EndTime>2015-10-01T06:51:51</EndTime>
              <BusyType>Busy</BusyType>
                        <CalendarEventDetails>
                        <ID>00000000B23AEBAC6379B34DBBBA0B525D2BBFD70700C26EC63E0E9E2A49B110258061BF491D000000FDECCA0000C26EC63E0E9E2A49B110258061BF491D0000D9385B8C0000</ID>
                        <Subject>Boardroom Tablet </Subject>
                        <IsMeeting>true</IsMeeting>
                        <IsRecurring>false</IsRecurring>
                        <IsException>false</IsException>
                        <IsReminderSet>false</IsReminderSet>
                        <IsPrivate>false</IsPrivate>
                        </CalendarEventDetails>
            </CalendarEvent>
          </CalendarEventArray>
          <WorkingHours xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
            <TimeZone>
              <Bias>300</Bias>
              <StandardTime>
                <Bias>0</Bias>
                <Time>02:00:00</Time>
                <DayOrder>1</DayOrder>
                <Month>11</Month>
                <DayOfWeek>Sunday</DayOfWeek>
              </StandardTime>
              <DaylightTime>
                <Bias>-60</Bias>
                <Time>02:00:00</Time>
                <DayOrder>2</DayOrder>
                <Month>3</Month>
                <DayOfWeek>Sunday</DayOfWeek>
              </DaylightTime>
            </TimeZone>
            <WorkingPeriodArray>
              <WorkingPeriod>
                <DayOfWeek>Monday Tuesday Wednesday Thursday Friday</DayOfWeek>
                <StartTimeInMinutes>480</StartTimeInMinutes>
                <EndTimeInMinutes>1140</EndTimeInMinutes>
              </WorkingPeriod>
            </WorkingPeriodArray>
          </WorkingHours>
        </FreeBusyView>
      </FreeBusyResponse>
    </FreeBusyResponseArray>
  </GetUserAvailabilityResponse>
</s:Body>
</s:Envelope>

To be able to call DeleteItem I need this Id in EwsLegacyId format instead of HexEntryId format, so I call ConvertId method:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
            <t:RequestServerVersion Version="Exchange2010" />
      </soap:Header>
      <soap:Body>
            <m:ConvertId DestinationFormat="EwsLegacyId">
                  <m:SourceIds>
                        <t:AlternateId Format="HexEntryId" Id="00000000B23AEBAC6379B34DBBBA0B525D2BBFD70700C26EC63E0E9E2A49B110258061BF491D000000FDECCA0000C26EC63E0E9E2A49B110258061BF491D0000D9385B940000"   Mailbox="BRDNYC-Collab2@mycompany.com" />
                  </m:SourceIds>
            </m:ConvertId>
      </soap:Body>
</soap:Envelope>

and I get 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header>
            <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="235" MinorBuildNumber="1" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
      </s:Header>
      <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
                  <m:ResponseMessages>
                        <m:ConvertIdResponseMessage ResponseClass="Success">
                              <m:ResponseCode>NoError</m:ResponseCode>
                              <m:AlternateId xsi:type="t:AlternateIdType" Format="EwsLegacyId" Id="AAAbAEJSRE5ZQy1Db2xsYWIyQGluZnVzaW9uLmNvbQBGAAAAAACyOuusY3mzTbu6C1JdK7/XBwDCbsY+Dp4qSbEQJYBhv0kdAAAA/ezKAADCbsY+Dp4qSbEQJYBhv0kdAADZOFuUAAA=" Mailbox="BRDNYC-Collab2@mycompany.com" />
                        </m:ConvertIdResponseMessage>
                  </m:ResponseMessages>
            </m:ConvertIdResponse>
      </s:Body>
</s:Envelope>

And when I try to call DeleteItem on this Id like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header/>
      <soap:Body>
            <m:DeleteItem DeleteType="MoveToDeletedItems" SendMeetingCancellations="SendToAllAndSaveCopy">
                  <m:ItemIds>
                        <t:ItemId Id="AAAbAEJSRE5ZQy1Db2xsYWIyQGluZnVzaW9uLmNvbQBGAAAAAACyOuusY3mzTbu6C1JdK7/XBwDCbsY+Dp4qSbEQJYBhv0kdAAAA/ezKAADCbsY+Dp4qSbEQJYBhv0kdAADZOFuUAAA=" />
                  </m:ItemIds>
            </m:DeleteItem>
      </soap:Body>
</soap:Envelope>

I get 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="235" MinorBuildNumber="1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
  </s:Header>
  <s:Body>
    <m:DeleteItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:DeleteItemResponseMessage ResponseClass="Error">
          <m:MessageText>Access is denied. Check credentials and try again.</m:MessageText>
          <m:ResponseCode>ErrorAccessDenied</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:DeleteItemResponseMessage>
      </m:ResponseMessages>
    </m:DeleteItemResponse>
  </s:Body>
</s:Envelope>

"Accees denied. Check credentials and try again"

1 个答案:

答案 0 :(得分:1)

在案例1中,您从日历中删除了您具有完全访问权限的约会。在Case2中,您似乎试图从Room Mailbox中删除您可能拥有或可能没有Full权限的约会(默认为只读,即使您是约会的组织者,您需要权利的日历本身) 。如果您是所述约会的组织者,您最好取消日历中的约会并将取消发送到房间邮箱,并让房间邮箱进程自动接受并以此方式执行删除或您需要分配尝试对相关房间邮箱执行删除完全访问权限的邮箱。

欢呼声 格伦