要解决ADFS CRM到SharePoint的问题,需要考虑以下几个方面:
Add-PSSnapin Microsoft.Adfs.PowerShell
$stsUrl = "https://adfs.example.com/adfs/services/trust"
$crmUrl = "https://crm.example.com"
$sharePointUrl = "https://sharepoint.example.com"
$relyingPartyName = "CRM"
$relyingPartyIdentifier = "urn:crm.example.com"
$tokenLifetime = (New-TimeSpan -Hours 8)
$crmRP = Get-AdfsRelyingPartyTrust -Name $relyingPartyName -ErrorAction SilentlyContinue
if ($crmRP -eq $null) {
$crmRP = New-AdfsRelyingPartyTrust -Name $relyingPartyName -Identifier $relyingPartyIdentifier -TokenLifetime $tokenLifetime
}
$crmRP | Set-AdfsRelyingPartyTrust -IssuanceTransformRules '@RuleTemplate = "PassThroughClaims"'
$crmRP | Add-AdfsRelyingPartyTrustIssuer -TrustedIssuerName "CRM" -TrustedIssuerUri $crmUrl
$crmRP | Add-AdfsRelyingPartyTrustEndpoint -Binding POST -Protocol WSFederation -Uri "$crmUrl/XRMServices/2011/Organization.svc"
$crmRP | Set-AdfsRelyingPartyTrust -WsFedEndpoint $stsUrl
$crmRP | Set-AdfsRelyingPartyTrust -IssuanceAuthorizationRules '@RuleTemplate = "AllowAllAuthzRule"'
$sharePointRP = Get-AdfsRelyingPartyTrust -Name "SharePoint" -ErrorAction SilentlyContinue
if ($sharePointRP -eq $null) {
$sharePointRP = New-AdfsRelyingPartyTrust -Name "SharePoint" -Identifier "urn:sharepoint.example.com" -TokenLifetime $tokenLifetime
}
$sharePointRP | Set-AdfsRelyingPartyTrust -IssuanceTransformRules '@RuleTemplate = "PassThroughClaims"'
$sharePointRP | Add-AdfsRelyingPartyTrustIssuer -TrustedIssuerName "SharePoint" -TrustedIssuerUri $sharePointUrl
$sharePointRP | Set-AdfsRelyingPartyTrust -WsFedEndpoint $stsUrl
$sharePointRP | Set-AdfsRelyingPartyTrust -IssuanceAuthorizationRules '@RuleTemplate = "AllowAllAuthzRule"'
using Microsoft.IdentityModel.Clients.ActiveDirectory;
string authority = "https://login.microsoftonline.com/{tenant_id}";
string clientId = "{client_id}";
string clientSecret = "{client_secret}";
string resource = "{crm_resource}";
AuthenticationContext authenticationContext = new AuthenticationContext(authority);
ClientCredential clientCredential = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(resource, clientCredential).Result;
string accessToken = authenticationResult.AccessToken;
这些解决方法应该有助于解决ADFS CRM到SharePoint的问题。但请注意,具体的实施细节可能会根据您的环境和需求而有所不同。