Share via


【IDM】AD FS で Event ID 323、364 が発生して認可されない場合の対処

みなさん、AD FS 使ってますか~? とかるーいノリで...。

たったいま、ハマった現象について覚書程度に記しておきます。

AD FSをインストールすると、規定の要求プロバイダーとして Active Directory が登録されます。

image

でもって、この要求プロバイダー"Active Directory"には、既定のクレームルールセットが登録されています。

image

この規定のクレームルールを削除してしまうと、認証方式や認証のタイムスタンプ等をRP(Relying Party)側に伝えることができなくなり、RP 側の STS からセキュリティトークン発行を拒否されてしまうことがあります(RP 側 STS の実装によります)。

拒否されると、イベントログには以下のようなイベントが出力されます。

image

フェデレーション サービスは、発信者 '' から証明書利用者 'https://tfazureforitpro.accesscontrol.windows.net/' へのサブジェクト 'Administrator' の代理としてのトークンの発行を承認できませんでした。 発信者 ID については、同じインスタンス ID を持つイベント 501 を参照してください。 OnBehalfOf ID (存在する場合) については、同じインスタンス ID を持つイベント 502 を参照してください。

インスタンス ID: d3c3c678-6bce-4fb5-90ee-f86810c4c53c

例外の詳細: Microsoft.IdentityServer.Service.IssuancePipeline.OnBehalfOfAuthorizationException: MSIS5009: 証明書利用者信頼 https://tfazureforitpro.accesscontrol.windows.net/ の発信者 ID および委任 システム 管理者 に対する偽装承認が失敗しました。 場所 Microsoft.IdentityModel.Threading.AsyncResult.End(IAsyncResult result) 場所 Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.ProcessCoreAsyncResult.End(IAsyncResult ar) 場所 Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.EndProcessCore(IAsyncResult ar, String requestAction, String responseAction, String trustNamespace) ユーザー操作 AD FS 2.0 の Windows PowerShell コメントを使用して、サブジェクトの代理の発信者が証明書利用者に対して承認されていることを確認してください。

image

パッシブな要求のフェデレーション中にエラーが発生しました。

追加データ

例外の詳細: Microsoft.IdentityServer.Web.RequestFailedException: MSIS7012: 要求の処理中にエラーが発生しました。詳細については、管理者に問い合わせてください。 ---> System.ServiceModel.FaultException: MSIS3126: アクセスが拒否されました。 場所 Microsoft.IdentityServer.Protocols.WSTrust.WSTrustClientManager.Issue(Message request, WCFResponseData responseData) 場所 Microsoft.IdentityServer.Protocols.WSTrust.WSTrustClient.Issue(RequestSecurityToken rst, WCFResponseData responseData) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.SubmitRequest(MSISRequestSecurityToken request) --- 内部例外スタック トレースの終わり --- 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.SubmitRequest(MSISRequestSecurityToken request) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.RequestBearerToken(MSISSignInRequestMessage signInRequest, SecurityTokenElement onBehalfOf, SecurityToken primaryAuthToken, String desiredTokenType, Uri& replyTo) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.RequestBearerToken(MSISSignInRequestMessage signInRequest, SecurityTokenElement onBehalfOf, SecurityToken primaryAuthToken, String desiredTokenType, MSISSession& session) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.BuildSignInResponseCoreWithSerializedToken(String signOnToken, WSFederationMessage incomingMessage) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.BuildSignInResponseCoreWithSecurityToken(SecurityToken securityToken, WSFederationMessage incomingMessage) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.BuildSignInResponseForProtocolRequest(FederationPassiveContext federationPassiveContext, SecurityToken securityToken) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.BuildSignInResponse(SecurityToken securityToken)

System.ServiceModel.FaultException: MSIS3126: アクセスが拒否されました。 場所 Microsoft.IdentityServer.Protocols.WSTrust.WSTrustClientManager.Issue(Message request, WCFResponseData responseData) 場所 Microsoft.IdentityServer.Protocols.WSTrust.WSTrustClient.Issue(RequestSecurityToken rst, WCFResponseData responseData) 場所 Microsoft.IdentityServer.Web.FederationPassiveAuthentication.SubmitRequest(MSISRequestSecurityToken request)

自分で設定したクレームルールに何の問題もないのに、このエラーが出た場合には、既定のルールを削除してしまったか変更してしまった可能性があります。

(参考)AD FS 2.0: Error Event 323, "MSIS5009: The impersonation authorization failed" and Event 364, "MSIS3126: Access denied" - TechNet Articles - Home - TechNet Wiki

そんなときは、ひとまず既定のルールセットを復旧しましょう。

当然、何が入っていたか覚えてますよね?

覚えていない!?なんてことでしょう!

そんな方のために、既定のルールセットの復旧手順が用意されています(私はこれに助けられました!)。

AD FS 2.0: How to Restore the Default Acceptance Transform Rules for the Active Directory Claims Provider Trust - TechNet Articles - Home - TechNet Wiki

※注意!この処理を行うと 要求プロバイダー"Active Directory" のクレームルールが初期化されます!
※必ず事前にクレームルールセットのバックアップを取りましょう
【IDM】AD FS で既存のクレームルールセットをバックアップするには

英語を読むのが面倒な方は以下をご覧ください。

1.以下のテキストを 丸ごとコピーして adcprules-default.txt というファイル名で保存してください。

AD FS に詳しい方であれば、以下がクレームルール言語で書かれてことがわかるはずです。

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Windows account name claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Name claims" c:[Type == "https://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Primary SID claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Group SID claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Primary group SID claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Deny only group SID claims" c:[Type == "https://schemas.xmlsoap.org/ws/2005/05/identity/claims/denyonlysid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Deny only primary SID claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Deny only primary group SID claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Authentication method claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

@RuleTemplate = "PassThroughClaims" @RuleName = "Pass through all Authentication time stamp claims" c:[Type == "https://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationinstant", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

2.PowerShell コンソールを開いてください

3.以下のコマンドレットを入力して、AD FS のスナップインを読み込んでください。

Add-PSSnapin Microsoft.Adfs.Powershell

4.以下のコマンドレットを入力して、保存したクレームルールセットを読み込んでください。

Set-AdfsClaimsProviderTrust -TargetName "Active Directory" -AcceptanceTransformRulesFile "adcprules-default.txt"

以上で完了です。

AD FS 管理コンソールで要求プロバイダー "Active Directory" のクレームルールを見ていただければ、元の状態に戻っていることがわかります。

繰り返しますが、この処理を行うと要求プロバイダー"Active Directory” に定義したクレームルールセットは消えてしまうので注意してください。

(参考)【IDM】AD FS で既存のクレームルールセットをバックアップするには