[英]Could not access delegated/impersonated shared mailbox via EWS
我正在尝试通过EWS使用全局管理员帐户凭据获取邮箱文件夹。 我正在将以下ruby脚本与Perspective gem一起使用。
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>'
谁可以帮我这个事?
终于找到了此错误的根本原因。 通常,共享邮箱不需要任何许可证。 Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guid
Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guid
当我们要访问未经许可的邮箱时,不会发生Could not retrieve folders. ErrorNonExistentMailbox: No mailbox with such guid
错误的邮箱。
当我尝试使用UserPrincipalName
而不是PrimarySmtpAddress
时,我能够访问邮箱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.