none
Microsoft.Exchange.WebServices.Data.ServiceResponseException: Unable to access an account or mailbox thrown for user having fullright access RRS feed

  • Question

  • I have two users a@company.com and b@companyu.com . I am trying to access b's mailboxfrom user a using EWS Managed API . User a has fullright permissions on b's mailbox. I can even open b's mailbox from a's account from Outlook Web Access.

    But when trying to access b's mailbox I am getting this exception.

    Microsoft.Exchange.WebServices.Data.ServiceResponseException: Unable to access an account or mailbox.

    Here is the relevant code

                var mailbox = new Mailbox("b@company.com");
                var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox);
                Folder lyncFolder;
                try
                {
                    // Getting  ServiceResponseException : Unable to access an account or mailbox                              
                    lyncFolder = Folder.Bind(_exchangeService, folderId);
                }
                catch (ServiceResponseException ex)
                {
                    _logger.Error(ex);
    
                        throw;
    
                }

    The behavior I have observed is when I open b's mailbox from a's account from OWA manually, the exception goes away and I can access b's mailbox from the code. And again later, the same exception again resurfaces randomly when I have to again open b's mailbox from a's account from OWA manually and the cycle continues. Any Idea?





    Tuesday, October 6, 2015 6:38 AM

All replies

  • I have two users a@company.com and b@companyu.com . I am trying to access b's mailboxfrom user a using EWS Managed API . User a has fullright permissions on b's mailbox. I can even open b's mailbox from a's account from Outlook Web Access.

    But when trying to access b's mailbox I am getting this exception.

    Microsoft.Exchange.WebServices.Data.ServiceResponseException: Unable to access an account or mailbox.

    Here is the relevant code

                var mailbox = new Mailbox("b@company.com");
                var folderId = new FolderId(WellKnownFolderName.Inbox, mailbox);
                Folder lyncFolder;
                try
                {
                    // Getting  ServiceResponseException : Unable to access an account or mailbox                              
                    lyncFolder = Folder.Bind(_exchangeService, folderId);
                }
                catch (ServiceResponseException ex)
                {
                    _logger.Error(ex);
    
                        throw;
    
                }

    The behavior I have observed is when I open b's mailbox from a's account from OWA manually, the exception goes away and I can access b's mailbox from the code. And again later, the same exception again resurfaces randomly when I have to again open b's mailbox from a's account from OWA manually and the cycle continues. Any Idea?





    Sounds like you need to give the account you are using applicationimpersonation rights,

    https://technet.microsoft.com/en-us/library/dd776119%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

    https://msdn.microsoft.com/en-us/library/office/dn722376(v=exchg.150).aspx

    http://www.techieshelp.com/exchange-2013-configuring-impersonation-applications/


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread

    Thursday, October 8, 2015 5:31 PM
  • Thanks Hinte,

    Right now we are following the delegation approach. And this approach is working for all other accounts except one. My only question is why this approach is not working as expected and shows some weird(may be of my limited knowledge. I am not an expert in exchange ) behavior. If I have to go through impersonation route  then there will be lot of design changes in my application and testings and so on.

    Friday, October 9, 2015 6:26 AM