0

I'm trying to access the calendar of other users via:

account = Account(
    primary_smtp_address=user,
    autodiscover=False,
    config=config,
    access_type=DELEGATE
)
items = account.calendar.filter(start__range=(start_date, end_date))

However, I'm getting Access is denied. Check credentials and try again., Cannot query rows in a table. I am able to access their calendars via UI so I'm not sure if permissions is exactly the problem here (their calendar is public within the organization) and I am also already able to query my own calendar just fine, it's just when it comes to other users that I run into this. Any ideas?

Edit 1: this is the failing XML call:

Response data: <?xml version='1.0' encoding='utf-8'?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo
    xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="20" MajorBuildNumber="3305" MinorBuildNumber="32" Version="V2018_01_08"/>
  </s:Header>
  <s:Body>
    <m:FindItemResponse
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:FindItemResponseMessage ResponseClass="Error">
          <m:MessageText>Access is denied. Check credentials and try again., Cannot query rows in a table.</m:MessageText>
          <m:ResponseCode>ErrorAccessDenied</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:FindItemResponseMessage>
      </m:ResponseMessages>
    </m:FindItemResponse>
  </s:Body>
</s:Envelope>

Also, unsure how helpful but, account.calendar.filter(start__range=(start_date, end_date)) returns just

QuerySet(q=start >= EWSDateTime(2020, 8, 26, 12, 18, 40, 194001, tzinfo=<DstTzInfo 'Europe/London' BST+1:00:00 DST>) AND start <= EWSDateTime(2020, 8, 28, 0, 0, tzinfo=<DstTzInfo 'Europe/London' BST+1:00:00 DST>), folders=[Calendar (Calendar)])

Request XML:

<?xml version='1.0' encoding='utf-8'?>
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <s:Header>
    <t:RequestServerVersion Version="Exchange2016"/>
    <t:TimeZoneContext>
      <t:TimeZoneDefinition Id="GMT Standard Time"/>
    </t:TimeZoneContext>
  </s:Header>
  <s:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning"/>
      <m:Restriction>
        <t:And>
          <t:IsGreaterThanOrEqualTo>
            <t:FieldURI FieldURI="calendar:Start"/>
            <t:FieldURIOrConstant>
              <t:Constant Value="2020-08-27T09:22:23+01:00"/>
            </t:FieldURIOrConstant>
          </t:IsGreaterThanOrEqualTo>
          <t:IsLessThanOrEqualTo>
            <t:FieldURI FieldURI="calendar:Start"/>
            <t:FieldURIOrConstant>
              <t:Constant Value="2020-08-28T00:00:00+01:00"/>
            </t:FieldURIOrConstant>
          </t:IsLessThanOrEqualTo>
        </t:And>
      </m:Restriction>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="calendar">
          <t:Mailbox>
            <t:EmailAddress>censored@company.com</t:EmailAddress>
            <t:RoutingType>SMTP</t:RoutingType>
            <t:MailboxType>Mailbox</t:MailboxType>
          </t:Mailbox>
        </t:DistinguishedFolderId>
      </m:ParentFolderIds>
    </m:FindItem>
  </s:Body>
</s:Envelope>
agermain
  • 122
  • 11
  • Try to enable debug logging to see which XML request is triggering this error on the server. Googling the error message does not give a lot of hints except permission errors and a possible bug in Exchange 2016: https://support.microsoft.com/en-ca/help/3196521/operation-failed-cannot-query-rows-in-a-table-error-during-finditems-o – Erik Cederstrand Aug 26 '20 at 07:06
  • You could try limiting the fields that you fetch by adding e.g. `.only('start', 'end', 'subject')` to the query. It's possible that the calendar contains private appointments that have fields that you don't have access to. – Erik Cederstrand Aug 26 '20 at 07:08
  • I've attached the XML of the failing call to the main question. I've tried to filter via start and end to no avail (knowing that I have access to see those events). Is `API version "Exchange2016" worked but server reports version "V2018_01_08". Using "Exchange2016"` worth of any value? – agermain Aug 26 '20 at 10:36
  • Updated main question with some more info as well. – agermain Aug 26 '20 at 11:20
  • You posted the reponse XML, but you're still missing the request XML. Can you post that? The API version thing causes no harm. – Erik Cederstrand Aug 27 '20 at 04:25
  • I've amended the question with the request XML. – agermain Aug 27 '20 at 08:25
  • Hmm. I don't see anything suspicious there :-/ – Erik Cederstrand Aug 31 '20 at 06:55

0 Answers0