基于服务器的 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 网站必须通过 Internet 进行访问。 反向代理可能要求 SharePoint 身份验证。 有关详细信息,请参阅 为 Server 2016 混合 SharePoint 配置反向代理设备。
SharePoint 网站必须配置为在 TCP 端口 443 上使用 SSL(HTTPS)(不支持自定义端口)并使用公共根证书颁发的证书。 如需了解详细信息,请参阅 SharePoint:关于安全通道 SSL 证书。
用于基于声明的身份验证在 SharePoint 和客户互动应用之间映射的一个可靠的用户属性。 有关详细信息,请参阅 选择声明映射类型。
若要共享文档,必须启用 SharePoint 搜索服务。 有关详细信息,请参阅 在 Server SharePoint 中创建和配置 Search Service 应用程序。
对于使用 Dynamics 365 移动应用时的文档管理功能,本地 SharePoint 服务器必须通过 Internet 可用。
其他先决条件
SharePoint Online 许可证。 客户互动应用至 SharePoint 内部部署的基于服务器的身份认证必须具有 Microsoft Entra ID 中注册的 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 服务器 SPN
在 SharePoint on-premises 服务器上,在 SharePoint 2016 Management Shell 中,按给定顺序运行这些 PowerShell 命令。
连接到 Microsoft 365。
运行 Connect-MgGraph 命令时,必须提供有效的 Microsoft 帐户,该帐户具有所需联机许可证的 SharePoint 全局管理员成员身份。
有关此处列出的 Microsoft Entra 每个 IDPowerShell 命令的详细信息,请转到使用 Windows PowerShell 进行管理 Microsoft Entra 。
Connect-MgGraph -Scopes "Directory.ReadWrite.All", "Application.ReadWrite.All"设置 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获取 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获取 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 on-premises 服务器上的 SharePoint 2016 Management Shell 中,运行 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
为 Microsoft Entra ID 在 SharePoint 上创建一个受信任安全令牌
在 SharePoint on-premises 服务器上,在 SharePoint 2016 Management Shell 中,按给定顺序运行这些 PowerShell 命令。
以下命令需要 SharePoint 场管理员成员资格。
有关这些 PowerShell 命令的详细信息,请转到 SharePoint 2016:PowerShell cmdlet 列表。
启用 PowerShell 会话更改 SharePoint 服务器场的安全令牌服务。
$c = Get-SPSecurityTokenServiceConfig $c.AllowMetadataOverHttp = $true $c.AllowOAuthOverHttp= $true $c.Update()设置元数据端点。
$metadataEndpoint = "https://login.microsoftonline.com/common/.well-known/openid-configuration" $oboissuer = "https://sts.windows.net/*/" $issuer = "00000007-0000-0000-c000-000000000000@" + $SPOContextId在 Microsoft Entra ID 中创建新令牌控制服务应用代理。
$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 Management Shell 中,按给定顺序运行这些 PowerShell 命令。
以下命令需要 SharePoint 网站集管理成员资格。
通过 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授予客户互动应用 SharePoint 站点的访问权限。 替换
<https://sharepoint.contoso.com/sites/crm/>为您的 SharePoint 网站网址。备注
在下面的示例中,通过使用 Scope 网站集参数,客户互动应用被授予对指定 SharePoint 网站集的访问权限。 Scope 参数接受以下选项: 选择最适合 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-
设置基于声明的身份验证映射类型。
重要提示
默认情况下,基于声明的身份验证映射使用用户的 Microsoft 帐户电子邮件地址和用户的 SharePoint 本地 工作电子邮件地址 进行映射。 使用基于声明的身份验证映射时,用户的电子邮件地址必须在两个系统之间匹配。 有关详细信息 ,请参阅选择基于声明的身份验证映射类型。
$Params = @{ IncomingClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" IncomingClaimTypeDisplayName = "EmailAddress" } $map1 = New-SPClaimTypeMapping @Params -SameAsIncoming
运行“启用基于服务器的 SharePoint 集成向导”
请按照以下步骤进行操作:
验证您是否具有运行该向导的适当权限。 在所需权限中了解更多信息。
转到设置>文档管理。
在文档管理区域中,单击启用基于服务器的 SharePoint 集成。
检查信息,然后单击下一步。
对于 SharePoint 网站,请单击内部部署,然后单击下一步。
输入 SharePoint 内部部署网站集 URL,如 https://sharepoint.contoso.com/sites/crm。 网站必须为 SSL 配置。
单击下一步。
验证网站节出现。 如果所有网站都确定为有效,请单击启用。 如果确定一个或多个站点无效,请转到 故障排除基于服务器的身份验证。
选择您要放入“文档管理”的实体
默认情况下,包括客户、文章、潜在顾客、产品、报价单和销售宣传资料实体。 您可以在文档管理设置 SharePoint 中 添加或删除用于文档管理的实体。 转到设置>文档管理。 在实体上 启用文档管理中了解更多信息。
添加 OneDrive for Business 集成
完成基于客户互动应用和 SharePoint on-premises 服务器的身份验证配置后,您还可以集成 OneDrive for Business。 利用客户互动应用和 OneDrive for Business 的集成,用户可以使用 OneDrive for Business 创建和管理专用文档。 在系统管理员启用 OneDrive Business 后,可以访问这些文档。
启用 OneDrive for Business
在运行 SharePoint Server on-premises 的 Windows Server 上,打开 SharePoint Management Shell 并运行以下命令。
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 应用程序概述。