SharePoint 2013技巧分享系列 - 同步Exchange顯示高清用戶照片

在“SharePoint 2013技巧分享系列 - Active Directory同步顯示用戶照片”文中介紹瞭如何同步Active Directory顯示用戶照片,但是同步完成後,用戶照片尺寸和清晰度都不是非常理想。本文將介紹如何同步Exchange Server顯示高清用戶照片。

原理

與SharePoint Server 2010相似, 在SharePoint Server 2013中存在一個用戶照片的目錄。當SharePoint啓用Exchange照片同步時, SharePoint將使用Exchange Server 2013 作爲照片存取目錄, 而SharePoint本地照片目錄將被屏蔽,也就是說,設置SharePoint-Exchange照片同步後,將不允許用戶通過SharePoint修改其頭像照片。在Central Administration - User Profile - Manage User Profiles中可以看到Picture屬性顯示“You can't change this person's photo because it is synchronized with Microsoft Exchange.". 

需要注意的是,在進行同步設置時,要對Exchange Server進行簡單的配置,並且需要重新啓動IIS。 而在SharePoint 2013中需要配置相關權限和服務,使SharePoint 2013能夠連接Exchange Server並獲取用戶數據。

環境實例

爲了避免誤解,這裏我們實現定義一些環境配置,方便在詳細步驟中調用:

1. SharePoint Server 2013 (http://people), 需要添加Alternate Access映射https://people. 該連接指向My Site。 

 

2. Exchange 2013 Client Access server (FQDN) http://e15fe.test.com。

3. Exchange 2013 Mailbox server (FQDN) http://e15be.test.com。 確認測試用戶帳號已經創建, 例如 [email protected]。 另外確認高清照片已經上傳。

4. 添加DNS record, 使autodiscover.test.com指向http://e15fe.test.com。

 

步驟

確認以上所有配置後,我們將進行以下幾個步驟的配置 。

第一步,添加Exchange 2013 Autodiscover服務,在Exchange Management Shell command中運行以下命令,

Get-ClientAccessServer | Set-ClientAccessServer -AutoDiscoverServiceInternalUri https://autodiscover.test.com/autodiscover/autodiscover.xml

 

第二步, SharePoint 2013 使用外部連接EWS和ECP讀取Exchange 2013 用戶照片數據。 現在我們需要使用Exchange Management Shell command運行,

Get-WebServicesVirtualDirectory | Set-WebServicesVirtualDirectory –InternalUrl https://e15fe.test.com/ews/exchange.asmx –ExternalUrl https://e15fe.test.com/ews/exchange.asmx

Get-EcpVirtualDirectory | Set-EcpVirtualDirectory –InternalUrl https://e15fe.test.com/ecp –ExternalUrl https://e15fe.test.com/ecp

 

第三步,完成以上Exchange server配置後,需要在SharePoint 2013安裝Exchange Web Services Managed API v2.0,並且將Microsoft.Exchange.WebServices.dll載入到GAC中。 這一步驟我們需要使用.NET 4中的命令GacUtil,所以,在進行這一步驟前,請確認.Net 4.0 SDK已經安裝在服務器上。完成安裝後,在PowerShell中運行以下命令載入Microsoft.Exchange.WebServices.dll。 載入完成後,需要重新啓動IIS。

Set-location "C:\Program Files\Microsoft\Exchange\Web Services\2.0"

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

$publish = New-Object System.EnterpriseServices.Internal.Publish

$publish.GacInstall("c:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll")

iisreset

 

第四步,在SharePoint 2013中配置S2SOAuth,使用SharePoint 2013 Management Shell command運行以下命令:

New-SPTrustedSecurityTokenIssuer -name "Exchange" -MetadataEndPoint "https://email.test.com/autodiscover/metadata/json/1"

$sts=Get-SPSecurityTokenServiceConfig

$sts.HybridStsSelectionEnabled = $true

$sts.AllowMetadataOverHttp = $false

$sts.AllowOAuthOverHttp = $false

$sts.Update()

$exchange=Get-SPTrustedSecurityTokenIssuer "Exchange"

$app=Get-SPAppPrincipal -Site http://people -NameIdentifier $exchange.NameId

$site=Get-SPSite http://people

Set-SPAppPrincipalPermission -AppPrincipal $app -Site $site.RootWeb -Scope sitesubscription -Right fullcontrol -EnableAppOnlyPolicy

 

第五步, 在Exchange server中配置S2SOAuth,在Exchange Management Shell中運行以下命令

cd \Program Files\Microsoft\Exchange Server\V15\Scripts>

.\Configure-EnterprisePartnerApplication.ps1 -AuthMetadataUrl https://people/_layouts/15/metadata/json/1 -ApplicationType sharepoint

完成以上命令後,需要重啓IIS,

iisreset e15fe

iisreset e15be

 

第六步,配置SharePoint 2013 和Exchange server照片同步

$wa = Get-SPWebApplication http://people

$wa.Properties["ExchangeAutodiscoverDomain"] = "email.test.com"

$wa.UserPhotoImportEnabled = $true

$wa.UserPhotoErrorExpiration = 1.0

$wa.UserPhotoExpiration = 6.0

$wa.Update()

 

完成以上步驟後,使用測試帳戶登陸進入http://people,刷新後即可從Exchange服務器獲取高清用戶照片。

需要注意的是,如果仍舊顯示Active Directory小照片,可以在Central Administration - User Profile Service - Manage User Properties中,編輯Picture屬性,刪除其中Active Directory映射的Property Mapping for Synchronization,然後”Start Full Profile Synchronization“即可。

 

對比顯示結果:

同步前

同步後

在http://people中大照片顯示對比更加明顯,這裏就不再上傳了。

如果你有更好的建議和方法,歡迎留言討論。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章