【问题标题】:Could not access delegated/impersonated shared mailbox via EWS无法通过 EWS 访问委派/模拟共享邮箱
【发布时间】:2018-07-24 13:42:00
【问题描述】:

我正在尝试通过 EWS 使用全局管理员帐户凭据获取邮箱文件夹。我正在使用以下带有视点 gem 的 ruby​​ 脚本来执行此操作。

require 'viewpoint'

include Viewpoint::EWS

endpoint = 'https://outlook.office365.com/ews/exchange.asmx'
admin_email = 'admin@hostname.com'
password = 'password'

user_email = "user@hostname.com"

cli = Viewpoint::EWSClient.new endpoint, admin_email, password
cli.set_impersonation 'PrimarySmtpAddress', user_email  #impersonation
act_as_hash = { act_as: user_email }
results = cli.folders(act_as_hash)

puts results.count

我已为所有邮箱创建了所需的权限和模拟。访问共享邮箱时遇到问题。我可以使用相同的脚本访问用户邮箱文件夹。

当我尝试使用上述脚本获取共享邮箱文件夹时,出现以下错误。

/Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:121:in `check_response': SOAP Error: Message: The primary SMTP address must be specified when referencing a mailbox.  Code: a:ErrorNonPrimarySmtpAddress (Viewpoint::EWS::Errors::SoapResponseError)
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:103:in `post'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/connection.rb:81:in `dispatch'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/soap/exchange_data_services.rb:503:in `find_folder'
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:45:in `folders'
    from o365_test_connection.rb:14:in `<main>'

我尝试评论模拟行并使用委托访问邮箱文件夹,但出现以下错误。

/Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:167:in `find_folders_parser': Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guid. (Viewpoint::EWS::EwsFolderNotFound)
    from /Users/yasitha/.rvm/gems/ruby-2.3.0/gems/viewpoint-1.1.0/lib/ews/folder_accessors.rb:46:in `folders'
    from o365_test_connection.rb:14:in `<main>'

谁能帮我解决这个问题?

【问题讨论】:

    标签: ruby office365 exchangewebservices impersonation viewpoint


    【解决方案1】:

    终于找到了这个错误的根本原因。通常共享邮箱不需要任何许可证。 Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guiderror 在我们访问未经许可的邮箱时发生。

    当我尝试UserPrincipalName 而不是PrimarySmtpAddress 时,我能够访问邮箱。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      相关资源
      最近更新 更多