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

前回以下の投稿をしました。

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

この投稿に関連し、既存のクレームルールセットをバックアップする方法についても紹介しておきます。クレームルールは大切なリソースですから、変更の前には必ずバックアップするようにしましょう。

AD FS には PowerShell 用コマンドレットが大量に用意されており、それらを使えばバックアップなんて簡単です。

AD FS 2.0 Cmdlets in Windows PowerShell

クレームルールセットを取得できるのは、以下の2つです。

  • Get-ADFSClaimsProviderTrust
    :要求プロバイダー信頼に関する情報の取得
  • Get-ADFSRelyingPartyTrust
    :証明書利用者信頼(RP)に関する情報の取得

いずれのコマンドレットも、出力のフォーマットは同様です。今回は、Get-ADFSClaimsProviderTrust を使用してみます。

PowerShell コンソールを開き、 以下のコマンドレットで AD FS スナップインを読み込んでください。

PS C:\>Add-PSSnapin Microsoft.Adfs.Powershell

要求プロバイダー名が "Active Directory" であれば、以下のようにして要求プロバイダーの情報を取得することができます。

PS C:\> Get-ADFSClaimsProviderTrust -Name "Active Directory"

出力結果の中に AcceptanceTransformRules というプロパティが用意されていますが、これがクレームルールセットです。

image

そこで、以下のように入力すると、以下のように、クレームルールセットのみを取得することができます。

PS C:\> $cp = Get-ADFSClaimsProviderTrust -Name "Active Directory" PS C:\> $cp.AcceptanceTransformRules

@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/primarygrou psid", 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/denyonlypri marysid", 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/denyonlypri marygroupsid", 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/authenticat ionmethod", 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/authenticat ioninstant", Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"] => issue(claim = c);

あとは、単純にテキストファイルに出力結果をリダイレクトすれば OK です。

PS C:\> $cp = Get-ADFSClaimsProviderTrust -Name "Active Directory" PS C:\> $cp.AcceptanceTransformRules > crs.bak

超簡単ですね。そして、Windows PowerShell って素敵ですね。