世紀(jì)互聯(lián)Office365 Exchange混合部署無法使用Microsoft Federation Gateway(MFG)查詢忙閑信息問題,配置OAuth步驟
在Office365 Exchange2013混合部署環(huán)境中,F(xiàn)ree/Busy忙/閑信息的查詢可以通過兩種方式:
- 通過Microsoft Federation Gateway以及本地和云端之間的Organizational RelationShip(由混合向?qū)?chuàng)建)
- 通過配置Open Authentication(OAuth)以及本地和云端的IntraOrganizationConnector來實(shí)現(xiàn)
而21V Office365無法使用傳統(tǒng)的日歷忙/閑信息共享(通過Microsoft Federation Gateway來進(jìn)行Free/Busy lookup),21V的Office365混合環(huán)境中,Exchange 2013雖然可以創(chuàng)建MFG,但是無法用來做忙/閑信息的查詢方式, 以下是世紀(jì)互聯(lián)版(21Vianet)Office365當(dāng)中手動配置OAuth的步驟,配置OAuth其實(shí)是有現(xiàn)成的向?qū)碜詣优渲茫怯行┣闆r下,向?qū)渲贸鰜砗螅琌Auth無法工作,這種情況下,可以嘗試手動配置,并且,對于本地Exchange 2013/Exchange 2010或者Exchange 2013/Exchange 2007 Mixed混合環(huán)境,也需要手動配置OAuth:
- 為Exchange Online組織創(chuàng)建授權(quán)服務(wù)器對象
在本地 Exchange Management Shell中運(yùn)行以下命令
New-AuthServer -Name "MicrosoftAzureACS" -AuthMetadataUrl https://accounts.accesscontrol.chinacloudapi.cn/<yourverified-domain>/metadata/json/1
運(yùn)行成功后,驗(yàn)證配置如下:
2. 為Exchange Online組織啟用Partner Application
Get-PartnerApplication | ?{$_.ApplicationIdentifier -eq "00000002-0000-0ff1-ce00-000000000000"-and $_.Realm -eq ""} | Set-PartnerApplication -Enabled $true
3. 導(dǎo)出本地授權(quán)證書
在此步驟中,你需要運(yùn)行腳本去導(dǎo)出本地的授權(quán)證書,然后導(dǎo)入到Exchange Online
將以下文本保存到名為 ExportAuthCert.ps1. 的PowerShell腳本文件中:
$thumbprint = (get-authconfig).CurrentCertificateThumbprintif((test-path $env:SYSTEMDRIVE\OAuthConfig) -eq $false){ md $env:SYSTEMDRIVE\OAuthConfig}cd $env:SYSTEMDRIVE\OAuthConfig $oAuthCert = (dir Cert:\LocalMachine\My) | where {$_.Thumbprint -match $thumbprint}$certType = [System.Security.Cryptography.X509Certificates.X509ContentType]::Cert$certBytes = $oAuthCert.Export($certType)$CertFile = "$env:SYSTEMDRIVE\OAuthConfig\OAuthCert.cer"[System.IO.File]::WriteAllBytes($CertFile, $certBytes)
在本地Exchange Management Shell當(dāng)中運(yùn)行腳本,如下圖:
4. 將本地授權(quán)證書上載到Azure Active Directory ACS
將以下腳本保存為 Azure-Auth.ps1
Connect-MsolService;
Import-Module msonlineextended;
$CertFile = "$env:SYSTEMDRIVE\OAuthConfig\OAuthCert.cer"
$objFSO = New-Object -ComObject Scripting.FileSystemObject;
$CertFile = $objFSO.GetAbsolutePathName($CertFile);
$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate
$cer.Import($CertFile);
$binCert = $cer.GetRawCertData();
$credValue = [System.Convert]::ToBase64String($binCert);
$ServiceName = "00000002-0000-0ff1-ce00-000000000000";
$p = Get-MsolServicePrincipal -ServicePrincipalName $ServiceName
New-MsolServicePrincipalCredential -AppPrincipalId $p.AppPrincipalId -Type asymmetric -Usage Verify -Value $credValue
然后使用 Azure AD powershell 運(yùn)行腳本(在彈出窗口輸入Office365全局管理員賬號密碼 )
5. 使用Azure Active Directory為外部本地Exchange HTTP端點(diǎn)注冊所有主機(jī)名頒發(fā)機(jī)構(gòu)
在此步驟中,您必須為每一臺發(fā)布到公網(wǎng)的本地Exchange服務(wù)器運(yùn)行此腳本,建議使用通配符,例:假設(shè)可通過 https://mail.contoso.com/ews/exchange.asmx從外部訪問Exchange。在這種情況下,就可以使用 *.contoso.com,可以涵蓋autodiscover.contoso.com和mail.contoso.com端點(diǎn)。不過,不會涵蓋頂級域contoso.com,如果Exchange 2013客戶端訪問服務(wù)器可通過頂級主機(jī)名頒發(fā)機(jī)構(gòu)從外部訪問,則您必須也將該主機(jī)名頒發(fā)機(jī)構(gòu)注冊為contoso.com.
將以下腳本保存為 RegisterEndpoints.ps1
$externalAuthority="*.contoso.com"
$ServiceName = "00000002-0000-0ff1-ce00-000000000000";
$p = Get-MsolServicePrincipal –ServicePrincipalName $ServiceName;
$spn = [string]::Format("{0}/{1}", $ServiceName, $externalAuthority);
$p.ServicePrincipalNames.Add($spn);
Set-MsolServicePrincipal –ObjectID $p.ObjectId –ServicePrincipalNames $p.ServicePrincipalNames;
在Azure AD PowerShell當(dāng)中運(yùn)行腳本:
6. 創(chuàng)建從本地到Office365的IntraOrganizationConnector
在本地Exchange PowerShell運(yùn)行以下命令:
New-IntraOrganizationConnector -name ExchangeHybridOnPremisesToOnline -DiscoveryEndpoint https://partner.outlook.cn/autodiscover/autodiscover.svc-TargetAddressDomains <contoso.partner.mail.onmschina.cn>
驗(yàn)證
7. 創(chuàng)建從Office365到本地的IntraOrganizationConnector
首先將Windows PowerShell連接到Exchange online(步驟https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx), 然后運(yùn)行以下命令:
New-IntraOrganizationConnector -name ExchangeHybridOnlineToOnPremises -DiscoveryEndpoint https://autodiscover.contoso.com/autodiscover/autodiscover.svc-TargetAddressDomains contoso.com
驗(yàn)證配置:
8. 為Exchange 2013 SP1之前的服務(wù)器配置AvailabilityAddressSpace
如果您本地有Exchange 2013 SP1之前版本的Exchange服務(wù)器,如Exchange 2010,請先確保您為這些服務(wù)器安裝了最新的RU補(bǔ)丁,然后配置如下的Address Space
Add-AvailabilityAddressSpace -AccessMethod InternalProxy –ProxyUrl <your on-premises External Web Services URL> -ForestName <your Office 365 service target address> -UseServiceAccount $True
驗(yàn)證配置
現(xiàn)在,您已配置完成,可以用以下步驟驗(yàn)證OAuth
在 Exchange 2013 server, 運(yùn)行以下命令:
Test-OAuthConnectivity -Service EWS -TargetUri https://partner.outlook.cn/ews/exchange.asmx-Mailbox <On-Premises Mailbox> -Verbose | fl
驗(yàn)證結(jié)果輸出為Success
2. 在Exchange Online PowerShell當(dāng)中,運(yùn)行以下命令:
Test-OAuthConnectivity -Service EWS -TargetUri <external hostname authority of your Exchange On-Premises deployment>/metadata/json/1 -Mailbox <Exchange Online Mailbox> -Verbose | fl
現(xiàn)在,您可以測試Free/Busy忙/閑信息共享是否工作正常(例:本地郵箱可以看O365郵箱的日歷忙/閑,O365郵箱可以看本地郵箱的日歷忙閑信息)