'Why am I receiving the 401 HTTP ERROR when calling GetSharedMailbox in Redemption?

I am using Redemption to access the shared mailboxes. The Logon method that I am using is Session.LogonExchangeMailbox.

It seems to be working fine as long as I do not try to access the shared mailbox. Once I am trying to access shared mailbox, there is the following error:

Redemption.RDOStores: Could not find the store DN Could not retrieve autodiscover XML: GetAutodiscoverForEmailAddress: There are no autodiscover servers in the AD for this address Error in WinHttpSendRequest(bcg.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_TIMEOUT Error in WinHttpSendRequest(bcgcloud.mail.onmicrosoft.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_NAME_NOT_RESOLVED Error in WinHttpSendRequest(autodiscover.bcgcloud.mail.onmicrosoft.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_CANNOT_CONNECT HTTP error 401 from https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml

What I tried:

  1. adding credentials with RDO.Credentials.add - does not change anything
  2. LogonHostedExchangeMailbox - does not work in my case at all - I guess because of Basic Auth being disabled (and I cannot get OAuth token for modern auth)

Checking the server version with Session.ExchangeMailboxServerVersion has shown that we have 15.20.4995.8 - looks like we have Exchange 2019 where RPC-Over-HTTP is not supported anymore. Then the question would be how could Session.LogonExchangeMailbox work at all even with DefaultFolder? Why does it error out only in case, if I am trying to access sharedmailbox?

Thanks.



Solution 1:[1]

It seems your choice is only the LogonHostedExchangeMailbox method. Here is what the author of Redemption wrote:

LogonExchangeMailbox creates a temporary profile that uses plain RPC connection. Exchange 2013 and 2016 do not support RPC connections anymore, only RPC-over-HTTP or MAPI-over-HTTP. You need to use LogonHostedExchangeMailbox for that.

See What is a RDOSession.LogonExchangeMailbox server name for outlook.com? for more information.

In case of Exchange profiles/accounts I'd suggest using EWS instead. See Explore the EWS Managed API, EWS, and web services in Exchange for more information. Also you may consider using the Graph API.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugene Astafiev