共用方式為


設定 SharePoint 內部部署的伺服器架構驗證

基於伺服器的 SharePoint 文檔管理集成用於將客戶互動應用 (Dynamics 365 Sales、Dynamics 365 Customer Service、 Dynamics 365 Field ServiceDynamics 365 Marketing 等 Dynamics 365 Project Service Automation) 與 SharePoint 本地連接起來。 使用基於伺服器的身份驗證時, Microsoft Entra 域服務 用作信任代理,使用者無需登錄 SharePoint。

需要的權限

啟用 SharePoint 文件管理需要以下成員資格和權限。

  • Microsoft 365 以下情況需要全域管理員成員身份:

    • 對 Microsoft 365 訂閱的管理層級存取權。
    • 執行啟用伺服器型驗證精靈。
    • 執行 AzurePowerShell Cmdlet。
  • Power Apps “運行 SharePoint 集成精靈 ”許可權允許“啟用基於伺服器的身份驗證”嚮導。

    根據預設,系統管理員資訊安全角色具備此權限。

  • 對於 SharePoint 本地集成, SharePoint 需要伺服器場管理員組成員身份才能在伺服器上 SharePoint 運行大多數 PowerShell 命令。

透過 SharePoint 內部部署設定伺服器對伺服器驗證

按照提供的順序,按照步驟設置 2016 本地客戶 SharePoint 互動應用。

重要

必須依照提供的順序完成此處所述的步驟。 如果任務未完成 (例如返回錯誤消息的 PowerShell 命令),則必須先解決問題,然後才能繼續執行下一個命令、任務或步驟。

確認先決條件

在您組態客戶參與應用程式和 SharePoint 內部部署進行伺服器架構驗證之前,必須符合下列先決條件:

SharePoint 先決條件

  • SharePoint 2016 (本地) Service Pack 1 (SP1) 或更高版本。

  • 安裝 2016 產品系列的 SharePoint 2025 年 5 月累積更新 (CU)。 此 2025 年 5 月 CU 包括自 SP1 以來發佈的所有 SharePoint 2016 修補程式,包括所有 SharePoint 2016 安全修補程式。 2025 年 5 月 CU 不包括 SP1。 在安裝 2025 年 5 月 CU 之前,需要先安裝 SP1。 有關詳細資訊,請參閱從官方 Microsoft 下載中心下載 Microsoft Enterprise Server 2016 的安全更新 (KB5002722) 和 SharePoint 2019 的詳細資訊,請轉到 從官方 Microsoft 下載中心 下載 Microsoft SharePoint Server 2019 Core 的安全更新 (KB5002708)。

  • SharePoint 設定:

    • 如果您使用 SharePoint 2016,對每個 SharePoint 陣列而言,只有一個客戶參與應用程式可針對伺服器架構整合進行組態。

    • 必須可以透過網際網路存取 SharePoint 網站。 SharePoint 驗證可能也需要反向 Proxy。 有關詳細資訊,請參閱 為 Server 2016 混合 SharePoint 配置反向代理設備。

    • SharePoint 網站必須配置為在 TCP 連接埠 443 上使用 SSL (HTTPS)(不支援自定義埠)並使用公共根證書頒發的證書。 如需瞭解詳細資訊,請參閱 SharePoint:關於安全通道 SSL 證書

    • 可靠的使用者屬性可用於 SharePoint 和客戶參與應用程式之間的宣告式驗證對應。 有關詳細資訊,請參閱 選擇聲明映射類型

    • 若要進行文件共用,SharePoint 搜尋服務必須啟用。 有關詳細資訊,請參閱 在 Server SharePoint 中創建和配置 Search Service 應用程式。

    • 使用 Dynamics 365 行動應用程式時,若要使用文件管理功能,內部部署 SharePoint 伺服器必須能夠透過網際網路提供。

其他先決條件

  • SharePoint Online 授權。 客戶參與應用程式對 SharePoint 內部部署伺服器的驗證必須在 Microsoft Entra 識別碼註冊 SharePoint 服務主體名稱 (SPN)。 要獲得訪問許可權,至少需要一個 SharePoint 在線用戶許可證。 SharePoint Online 授權可以從單一使用者授權衍生,而且通常隨附下列其中一項:

    • SharePoint Online 訂閱。 任何 SharePoint Online 方案都充足,即使未指派授權給使用者。

    • 包含 SharePoint Online 的 Microsoft 365 訂閱。 例如,如果您有 Microsoft 365 E3,就有適當的授權,即使未指派授權給使用者。

      有關這些計劃的詳細資訊,請轉到 查找適合您的 解決方案和 比較 SharePoint 選項

  • 運行本文中所述的 PowerShell cmdlet 需要以下軟體功能。

    Microsoft.Graph

    若要安裝 Microsoft.Graph 模組,請從管理員 PowerShell 會話中輸入以下命令。

    $currentMaxFunctionCount =
        $ExecutionContext.SessionState.PSVariable.Get("MaximumFunctionCount").Value
    
    # Set execution policy to RemoteSigned for this session
    if ((Get-ExecutionPolicy -Scope Process) -ne "RemoteSigned") {
        Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force
    }
    
    # Update MaximumFunctionCount if needed
    if ($currentMaxFunctionCount -lt 32768) {
        $ExecutionContext.SessionState.PSVariable.Set("MaximumFunctionCount", 32768)
    }
    
    # Install and import required modules
    if (-not (Get-Module -ListAvailable -Name "Microsoft.Graph")) {
        $Params = @{
            Name = "Microsoft.Graph"
            Scope = CurrentUser
        }
        Install-Module @Params -Force
    }
    
    $Params = @{
        Name = "Microsoft.Graph"
        Function = @("Connect-MgGraph", "Get-MgOrganization")
    }
    Import-Module @Params
    
    if (-not (Get-Module -ListAvailable -Name "Microsoft.Graph.Identity.DirectoryManagement")) {
        $Params = @{
            Name = "Microsoft.Graph.Identity.DirectoryManagement"
            Scope = CurrentUser
        }
        Install-Module @Params -Force
    }
    
    $Params = @{
        Name = "Microsoft.Graph.Identity.DirectoryManagement"
        Function = @("Get-MgServicePrincipal", "Update-MgServicePrincipal")
    }
    Import-Module @Params
    
  • 適合的宣告式驗證對應類型可用於客戶參與應用程式和 SharePoint 內部部署之間的對應身份。 預設會使用電子郵件地址。 在授予 Customer Engagement 應用訪問和配置基於聲明的身份驗證映射的 許可權中了解 SharePoint 詳細資訊

更新 Microsoft Entra 網域服務中的 SharePoint Server SPN

在 SharePoint on-premises 伺服器的 SharePoint 2016 管理命令介面中,依指定順序執行下列 PowerShell 命令。

  1. 連線至 Microsoft 365。

    運行 Connect-MgGraph 命令時,必須提供有效的 Microsoft 帳戶,該帳戶具有所需連線許可證的 SharePoint 全域管理員成員身份。

    有關此處列出的 Microsoft Entra 每個 IDPowerShell 命令的詳細資訊,請轉到使用 Windows PowerShell 進行管理 Microsoft Entra

    Connect-MgGraph -Scopes "Directory.ReadWrite.All", "Application.ReadWrite.All"  
    
  2. 設置 SharePoint 主機 URL。

    為變數 HostNameUrl 設置的值必須是網站集的完整 SharePoint 主機名 URL。 主機名稱必須衍生自網站集合 URL 並且區分大小寫。 在此示例中,網站集 URL 是, https://SharePoint.constoso.com/sites/salesteam因此主機名 URL 是 https://SharePoint.contoso.com

    重要

    如果有多個網站,請為每個網站運行以下命令。

    # Generate Service Principal Name
    # Note: If there are multiple sites, and the host is the same, no action is needed.
    #       If the host is different, each site needs to be configured to add the 
    #       host to the service principal.
    $uri = [System.Uri]"https://SharePoint.constoso.com/sites/salesteam"
    $hostName = $uri.Host
    $baseUrl = "$($uri.Scheme)://$hostName"
    $servicePrincipalName = $baseUrl
    
  3. 取得 Microsoft 365 物件 (租戶) ID 和 SharePoint 伺服器服務主體名稱 (SPN)。

    # SharePoint Online App ID
    $SPOAppId = "00000003-0000-0ff1-ce00-000000000000"
    
    # Retrieve SharePoint Online Service Principal
    $SharePoint = Get-MgServicePrincipal -Filter "AppId eq '$SPOAppId'"
    
    $UpdatedServicePrincipalNames = $SharePoint.ServicePrincipalNames |
        Where-Object { $_ -ne $servicePrincipalName }
    $UpdatedServicePrincipalNames += $servicePrincipalName
    
  4. 取得 Microsoft 365 物件 (租戶) ID 和 SharePoint 伺服器服務主體名稱 (SPN)。

    $maxRetries = 5
    $retryDelay = 5 # seconds 
    
    for ($retry = 1; $retry -le $maxRetries; $retry++) {
        try {
            $Params = @{
     	         ServicePrincipalId = $SharePoint.Id
     			     ServicePrincipalNames = $UpdatedServicePrincipalNames
     		   }
     		   Update-MgServicePrincipal @Params
     		   Write-Host "Service Principal Names updated successfully."
     		   break
     	 }
     	 catch {
     		   if ($_.Exception.Message -match "Directory_ConcurrencyViolation" -and
                $retry -lt $maxRetries) {
     			     Write-Host "Concurrency violation detected. (Attempt $retry of $maxRetries)"
     			     Start-Sleep -Seconds $retryDelay
       		 }
       		 else {
         			 Write-Host "Failed to update Service Principal Names. Error: $_"
     		    	 exit 1
            }
        }
    }
    

完成這些命令后,請勿關閉 SharePoint 2016 命令行管理程式。 繼續下一步。

更新 SharePoint 領域以符合 SharePoint Online 的領域

在 SharePoint 內部部署伺服器的 SharePoint 2016 管理命令介面中,執行這個 Windows PowerShell 命令。

下列命令需要 SharePoint 伺服器陣列管理員成員資格,該命令會設定 SharePoint 內部部署伺服陣列的驗證領域。

注意

執行這個命令會變更 SharePoint 內部部署伺服陣列的驗證領域。 對於使用現有安全令牌服務 (STS) 的應用程式,此命令可能會導致使用訪問令牌的其他應用程式出現意外行為。 在 Set-SPAuthenticationRealm 瞭解更多資訊。

# SPOContextId is the tenant ID for the dynamics 365 tenant. It is used to identify the tenant in Azure AD and SharePoint Online.
$SPOContextId = "<tenantId>"
Set-SPAuthenticationRealm -Realm $SPOContextId

為 SharePoint 上的 Microsoft Entra ID 建立信任的安全性權杖簽發者

在 SharePoint on-premises 伺服器的 SharePoint 2016 管理命令介面中,依指定順序執行下列 PowerShell 命令。

下列命令需要 SharePoint 伺服器陣列管理員成員資格。

如需這些 PowerShell 命令的詳細資訊,請移至 SharePoint 2016:PowerShell Cmdlet 清單

  1. 啟用 PowerShell 工作階段,對 SharePoint 伺服陣列的 Security Token Service 進行變更。

    $c = Get-SPSecurityTokenServiceConfig  
    $c.AllowMetadataOverHttp = $true  
    $c.AllowOAuthOverHttp= $true  
    $c.Update()  
    
  2. 設定中繼資料端點。

    $metadataEndpoint = 
        "https://login.microsoftonline.com/common/.well-known/openid-configuration"  
    $oboissuer = "https://sts.windows.net/*/" 
    $issuer = "00000007-0000-0000-c000-000000000000@" + $SPOContextId  
    
  3. 在 Microsoft Entra 識別碼中建立新的 Token 控制服務應用程式 Proxy。

    $existingIssuer = Get-SPTrustedSecurityTokenIssuer "D365Obo"
    if ($existingIssuer) {
        $Params = @{
            Identity = $existingIssuer
            IsTrustBroker = $true
            MetadataEndpoint = $metadataEndpoint
            RegisteredIssuerName = $oboissuer
        }
        Set-SPTrustedSecurityTokenIssuer @Params
    } else {
        $Params = @{
            Name = "D365Obo"
            IsTrustBroker = $true
            MetadataEndpoint = $metadataEndpoint
            RegisteredIssuerName = $oboissuer
        }
        $obo = New-SPTrustedSecurityTokenIssuer @Params
    }
    

授與客戶參與應用程式對 SharePoint 的存取權限並組態宣告式驗證對應

在 SharePoint on-premises 伺服器的 SharePoint 2016 管理命令介面中,依指定順序執行下列 PowerShell 命令。

下列命令需要 SharePoint 網站集合管理成員資格。

  1. 使用 SharePoint 網站集合註冊客戶參與應用程式。

    輸入 SharePoint 內部部署網站集合 URL。 在本例中,使用。 <https://sharepoint.contoso.com/sites/crm/>

    $site = Get-SPSite "https://sharepoint.contoso.com/sites/crm/"
    $Params = @{
        site = $site.RootWeb
        NameIdentifier = $issuer
        DisplayName = "crmobo"
    }
    Register-SPAppPrincipal @Params
    
  2. 授予客戶參與應用程式對 SharePoint 網站的存取權。 替換 <https://sharepoint.contoso.com/sites/crm/> 為您的 SharePoint 網站網址。

    注意

    在下列範例中,使用 –Scope 網站集合參數授與客戶參與應用程式對特定 SharePoint 網站集合的權限。 範圍參數接受下列選項。 選擇最適合您的 SharePoint 設定的範圍。

    • site。 只將客戶參與應用程式權限授與特定的 SharePoint 網站。 這不會將權限授與具名網站下的任何子網站。
      • sitecollection。 將客戶參與應用程式權限授與所有網站及特定 SharePoint 網站集合中的子網站。
      • sitesubscription。 將客戶參與應用程式權限授與 SharePoint 陣列中的所有網站,包括所有網站集合、網站和子網站。

    重要

    如果有多個網站,請為每個網站運行腳本。

    $Params = @{
        NameIdentifier = $issuer
        Site = "https://sharepoint.contoso.com/sites/crm/"
    }
    $app = Get-SPAppPrincipal @Params
    
    $Params = @{
        AppPrincipal = $app
        Site = $site.Rootweb
        Scope = "sitecollection"
        Right = "FullControl"
    }
    Set-SPAppPrincipalPermission @Params
    
  3. 設定宣告型驗證設定對應類型。

    重要

    默認情況下,基於聲明的身份驗證映射使用使用者的 Microsoft 帳戶電子郵件地址和使用者的 SharePoint 本地 工作電子郵件地址 進行映射。 使用基於聲明的身份驗證映射時,用戶的電子郵件地址必須在兩個系統之間匹配。 有關詳細資訊 ,請參閱選擇基於聲明的身份驗證映射類型

    $Params = @{
        IncomingClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
        IncomingClaimTypeDisplayName = "EmailAddress"
    }
    $map1 = New-SPClaimTypeMapping @Params -SameAsIncoming
    

執行啟用伺服器架構 SharePoint 整合精靈

執行下列步驟:

  1. 確定您具有適當的權限可以執行精靈。 在需要的權限中了解詳細資訊。

  2. 移至設定>文件管理

  3. 文件管理區域中,按一下啟用伺服器架構 SharePoint 整合

  4. 檢閱資訊,然後按下一步

  5. 對於 SharePoint 網站,按一下內部部署,然後按下一步

  6. 輸入 SharePoint 內部部署網站集合 URL,例如 https://sharepoint.contoso.com/sites/crm。 該網站必須已設定成使用 SSL。

  7. 下一步

  8. 驗證網站區段隨即出現。 如果所有網站皆判定為有效,請按一下啟用。 如果確定一個或多個網站無效,請轉到 故障排除基於伺服器的身份驗證

選取要包含在文件管理中的實體

預設會包含客戶、文章、潛在客戶、產品、報價及銷售文宣實體。 您可以在文件管理設定 SharePoint 中 添加或刪除用於文件管理的實體。 移至設定>文件管理。 在實體上 啟用文件管理中瞭解更多資訊。

新增商務用 OneDrive 整合

完成客戶參與應用程式及 SharePoint 內部部署伺服器架構驗證組態之後,您也可以整合商務用 OneDrive。 使用者可使用客戶參與應用程式與商務用 OneDrive 整合建立和管理使用商務用 OneDrive 的私人文件。 在系統管理員啟用 OneDrive Business 后,可以訪問這些文檔。

啟用商務用 OneDrive

在 SharePoint On-Premises 執行所在的 Windows Server,開啟 SharePoint 管理命令介面並執行以下命令:

Add-Pssnapin *  

# Access WellKnown App principal  
[Microsoft.SharePoint.Administration.SPWebService]::ContentService.WellKnownAppPrincipals  
  
# Create WellKnown App principal  
$ClientId = "00000007-0000-0000-c000-000000000000"  
$PermissionXml = @"
<AppPermissionRequests AllowAppOnlyPolicy="true">
    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
    <AppPermissionRequest Scope="http://sharepoint/social/tenant" Right="Read" />
    <AppPermissionRequest Scope="http://sharepoint/search" Right="QueryAsUserIgnoreAppPrincipal" />
</AppPermissionRequests>
"@

$wellKnownApp = New-Object `
    -TypeName "Microsoft.SharePoint.Administration.SPWellKnownAppPrincipal" `
    -ArgumentList ($ClientId, $PermissionXml)  
  
$wellKnownApp.Update()    

選擇宣告型驗證設定對應類型

默認情況下,基於聲明的身份驗證映射使用使用者的 Microsoft 帳戶電子郵件地址和使用者的 SharePoint 本地工作電子郵件地址進行映射。 無論使用哪種基於聲明的身份驗證類型,值 (如電子郵件位址) 都必須在 Customer Engagement 應用和 之間匹配 SharePoint。 Microsoft 365 目錄同步有助於電子郵件位址匹配。 在部署目錄同步 中 Microsoft 365 Microsoft Azure瞭解更多資訊。 若要使用不同類型的基於聲明的身份驗證映射,請轉到為 基於伺服器的集成 SharePoint 定義自定義聲明映射。

重要

若要啟用工作電子郵件屬性,SharePoint 內部部署必須已設定並啟動 User Profile Service 應用程式。 若要啟用 SharePoint User Profile Service 應用程式,請轉到在 Server 2016 中 SharePoint 創建、編輯或刪除 User Profile Service 應用程式。 要更改使用者屬性 (例如工作電子郵件),請轉到 修改使用者配置檔屬性。 有關 User Profile Service 應用程式的詳細資訊,請轉到 Server 2016 中的 SharePoint User Profile Service 應用程式概述