交换网络服务 (EWS) 显示"Accees denied"当我尝试删除我创建的日历事件时



我正在尝试删除一个刚刚创建的日历事件。

案例1:

  • 我调用EWS,使用域用户broom@infusion.com的凭据在一些房间创建一个日历事件,提供房间的电子邮件地址,然后我得到事件的ID
  • 然后我通过调用EWS并提供Id和ChangeKey删除事件,一切正常-会议被删除

案例2

  • 我创建事件的方式与案例1
  • 相同我得到这个房间的日历事件列表。现在事件的ID是HexEntryId格式。因此,我使用ConvertId方法将其转换为DeleteItem方法所需的EwsLegacyId
  • 我调用DeleteItem方法与ConvertId方法提供的事件ID,但没有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中,您从日历中删除您拥有完全访问权限的约会。在案例2中,看起来您试图从Room Mailbox中删除约会,您可能有也可能没有完全权限(默认为只读,即使您是约会的组织者,您也需要日历本身的权限)。如果您是上述约会的组织者,您最好在日历中取消约会,并将取消通知发送到Room邮箱,让Room邮箱上的自动接受处理并以这种方式执行删除操作,或者您需要为正在尝试对相关Room邮箱执行"完全删除"访问的邮箱分配邮箱。

干杯格伦

最新更新