Windows Server での AD FS 用のカスタム認証方法を構築する

このチュートリアルでは、Windows Server 2012 R2 で AD FS 用のカスタム認証方法を実装する手順について説明します。 詳細は、「追加の認証方法」をご確認ください。

警告

ここで構築できる例は、教育のみを目的とします。  これらの手順は、モデルの必要な要素を公開するために可能な最も単純で最小限の実装用です。  認証バックエンド、エラー処理、または構成データはありません。

開発ボックスの設定

このチュートリアルでは、Visual Studio 2012 を使用します。 プロジェクトは、Windows 用の .NET クラスを作成できる任意の開発環境を使用してビルドできます。 BeginAuthentication メソッドと TryEndAuthentication メソッドは .NET Framework バージョン 4.5 の一部である System.Security.Claims.Claim を使用するため、プロジェクトは .NET 4.5 を対象とする必要があります。 プロジェクトに必要な参照が 1 つあります:

参照 dll 参照先 次のために必須:
Microsoft.IdentityServer.Web.dll dll は、AD FS がインストールされている Windows Server 2012 R2 サーバーの%windir%\ADFS にあります。

この dll は、開発用コンピューターにコピーし、プロジェクトに明示的に参照を作成する必要があります。

IAuthenticationContext、IProofData を含むインターフェイス型

プロバイダーの作成

  1. Visual Studio 2012 の場合: [ファイル]、[>新規作成]、[>プロジェクト] の順にクリックします。

  2. クラス ライブラリを選択し、.NET 4.5 を対象としていることを確認します。

    Screenshot of the New Project dialog box showing the Class Library option selected.

  3. AD FS がインストールされている Windows Server 2012 R2 サーバーで%windir%\ADFS から Microsoft.IdentityServer.Web.dll のコピーを作成し、開発用コンピューターの Project フォルダーに貼り付けます。

  4. ソリューション エクスプローラーで、[参照] を右クリックし、[参照の追加] をクリックします。

  5. Microsoft.IdentityServer.Web.dll のローカルコピーおよび [追加] を参照します

  6. [OK] をクリックして、次の参照を確認します:

    Screenshot of the Reference Manager dialog box showing the Microsoft.IdentityServer.Web.dll selected.

    これで、プロバイダーに必要なすべての型を解決するように設定されました。

  7. プロジェクトに新しいクラスを追加し (プロジェクトを右クリックし、追加... クラス...)、次に示すように、 MyAdapter のような名前を付けます:

    Screenshot of the Add New Item dialog box with the Class option selected.

  8. 新しいファイル MyAdapter .cs で、既存のコードを次のコードに置き換えます。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Globalization;
    using System.IO;
    using System.Net;
    using System.Xml.Serialization;
    using Microsoft.IdentityServer.Web.Authentication.External;
    using Claim = System.Security.Claims.Claim;
    
    namespace MFAadapter
    {
        class MyAdapter : IAuthenticationAdapter
        {
            public IAuthenticationAdapterMetadata Metadata
            {
                //get { return new <instance of IAuthenticationAdapterMetadata derived class>; }
            }
    
            public IAdapterPresentation BeginAuthentication(Claim identityClaim, HttpListenerRequest request, IAuthenticationContext authContext)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
    
            public bool IsAvailableForUser(Claim identityClaim, IAuthenticationContext authContext)
            {
                return true; //its all available for now
            }
    
            public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)
            {
                //this is where AD FS passes us the config data, if such data was supplied at registration of the adapter
            }
    
            public void OnAuthenticationPipelineUnload()
            {
    
            }
    
            public IAdapterPresentation OnError(HttpListenerRequest request, ExternalAuthenticationException ex)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
    
            public IAdapterPresentation TryEndAuthentication(IAuthenticationContext authContext, IProofData proofData, HttpListenerRequest request, out Claim[] outgoingClaims)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
    
        }
    }
    
  9. まだビルドする準備ができていません...さらに 2 つのインターフェイスがあります。

    2 つ以上のクラスをプロジェクトに追加します。1 つはメタデータ用で、もう 1 つはプレゼンテーション フォーム用です。 上記のクラスと同じファイル内にこれらを追加できます。

    class MyMetadata : IAuthenticationAdapterMetadata
    {
    
    }
    
    class MyPresentationForm : IAdapterPresentationForm
    {
    
    }
    
  10. 次に、それぞれに必要なメンバーを追加できます。最初はメタデータ (有用なインライン コメントを含む)

    class MyMetadata : IAuthenticationAdapterMetadata
    {
        //Returns the name of the provider that will be shown in the AD FS management UI (not visible to end users)
        public string AdminName
        {
            get { return "My Example MFA Adapter"; }
        }
    
        //Returns an array of strings containing URIs indicating the set of authentication methods implemented by the adapter 
        /// AD FS requires that, if authentication is successful, the method actually employed will be returned by the
        /// final call to TryEndAuthentication(). If no authentication method is returned, or the method returned is not
        /// one of the methods listed in this property, the authentication attempt will fail.
        public virtual string[] AuthenticationMethods 
        {
            get { return new[] { "http://example.com/myauthenticationmethod1", "http://example.com/myauthenticationmethod2" }; }
        }
    
        /// Returns an array indicating which languages are supported by the provider. AD FS uses this information
        /// to determine the best language\locale to display to the user.
        public int[] AvailableLcids
        {
            get
            {
                return new[] { new CultureInfo("en-us").LCID, new CultureInfo("fr").LCID};
            }
        }
    
        /// Returns a Dictionary containing the set of localized friendly names of the provider, indexed by lcid. 
        /// These Friendly Names are displayed in the "choice page" offered to the user when there is more than 
        /// one secondary authentication provider available.
        public Dictionary<int, string> FriendlyNames
        {
            get
            {
                Dictionary<int, string> _friendlyNames = new Dictionary<int, string>();
                _friendlyNames.Add(new CultureInfo("en-us").LCID, "Friendly name of My Example MFA Adapter for end users (en)");
                _friendlyNames.Add(new CultureInfo("fr").LCID, "Friendly name translated to fr locale");
                return _friendlyNames;
            }
        }
    
        /// Returns a Dictionary containing the set of localized descriptions (hover over help) of the provider, indexed by lcid. 
        /// These descriptions are displayed in the "choice page" offered to the user when there is more than one 
        /// secondary authentication provider available.
        public Dictionary<int, string> Descriptions
        {
            get 
            {
                Dictionary<int, string> _descriptions = new Dictionary<int, string>();
                _descriptions.Add(new CultureInfo("en-us").LCID, "Description of My Example MFA Adapter for end users (en)");
                _descriptions.Add(new CultureInfo("fr").LCID, "Description translated to fr locale");
                return _descriptions; 
            }
        }
    
        /// Returns an array indicating the type of claim that the adapter uses to identify the user being authenticated.
        /// Note that although the property is an array, only the first element is currently used.
        /// MUST BE ONE OF THE FOLLOWING
        /// "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname"
        /// "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"
        /// "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
        /// "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid"
        public string[] IdentityClaims
        {
            get { return new[] { "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn" }; }
        }
    
        //All external providers must return a value of "true" for this property.
        public bool RequiresIdentity
        {
            get { return true; }
        }
    }
    

    これで、IAuthenticationAdapter で F12 キー (右クリックで [定義に進む]) を使用して、必要なインターフェイス メンバーのセットを確認できるようになります。

    次に、これらの実装を行うことができます。

  11. クラスの内容全体を次のコードで置き換えます:

    namespace MFAadapter
    {
        class MyAdapter : IAuthenticationAdapter
        {
            public IAuthenticationAdapterMetadata Metadata
            {
                //get { return new <instance of IAuthenticationAdapterMetadata derived class>; }
            }
    
            public IAdapterPresentation BeginAuthentication(Claim identityClaim, HttpListenerRequest request, IAuthenticationContext authContext)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
    
            public bool IsAvailableForUser(Claim identityClaim, IAuthenticationContext authContext)
            {
                return true; //its all available for now
            }
    
            public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)
            {
                //this is where AD FS passes us the config data, if such data was supplied at registration of the adapter
            }
    
            public void OnAuthenticationPipelineUnload()
            {
    
            }
    
            public IAdapterPresentation OnError(HttpListenerRequest request, ExternalAuthenticationException ex)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
    
            public IAdapterPresentation TryEndAuthentication(IAuthenticationContext authContext, IProofData proofData, HttpListenerRequest request, out Claim[] outgoingClaims)
            {
                //return new instance of IAdapterPresentationForm derived class
            }
        }
    }
    

    次に、プレゼンテーションフォームを示します:

    class MyPresentationForm : IAdapterPresentationForm
    {
        /// Returns the HTML Form fragment that contains the adapter user interface. This data will be included in the web page that is presented
        /// to the cient.
        public string GetFormHtml(int lcid)
        {
            string htmlTemplate = Resources.FormPageHtml; //todo we will implement this
            return htmlTemplate;
        }
    
        /// Return any external resources, ie references to libraries etc., that should be included in
        /// the HEAD section of the presentation form html.
        public string GetFormPreRenderHtml(int lcid)
        {
            return null;
        }
    
        //returns the title string for the web page which presents the HTML form content to the end user
        public string GetPageTitle(int lcid)
        {
            return "MFA Adapter";
        }
    }
    
  12. 上の Resources.FormPageHtml 要素の ' todo ' に注意してください。 1 分以内に修正できますが、最初に、新しく実装された型に基づいて、最後に必要な戻りステートメントを最初の MyAdapter クラスに追加してみましょう。 これを行うには、既存の IAuthenticationAdapter 実装に次を追加します:

    class MyAdapter : IAuthenticationAdapter
    {
        public IAuthenticationAdapterMetadata Metadata
        {
            //get { return new <instance of IAuthenticationAdapterMetadata derived class>; }
            get { return new MyMetadata(); }
        }
    
        public IAdapterPresentation BeginAuthentication(Claim identityClaim, HttpListenerRequest request, IAuthenticationContext authContext)
        {
            //return new instance of IAdapterPresentationForm derived class
            return new MyPresentationForm();
        }
    
        public bool IsAvailableForUser(Claim identityClaim, IAuthenticationContext authContext)
        {
            return true; //its all available for now
        }
    
        public void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)
        {
            //this is where AD FS passes us the config data, if such data was supplied at registration of the adapter
        }
    
        public void OnAuthenticationPipelineUnload()
        {
    
        }
    
        public IAdapterPresentation OnError(HttpListenerRequest request, ExternalAuthenticationException ex)
        {
            //return new instance of IAdapterPresentationForm derived class
            return new MyPresentationForm();
        }
    
        public IAdapterPresentation TryEndAuthentication(IAuthenticationContext authContext, IProofData proofData, HttpListenerRequest request, out Claim[] outgoingClaims)
        {
            //return new instance of IAdapterPresentationForm derived class
            outgoingClaims = new Claim[0];
            return new MyPresentationForm();
        }
    
    }
    
  13. ここで、html フラグメントを含むリソース ファイルを使用します。 次の内容を含む新しいテキスト ファイルをプロジェクト フォルダーに作成します:

    <div id="loginArea">
        <form method="post" id="loginForm" >
            <!-- These inputs are required by the presentation framework. Do not modify or remove -->
            <input id="authMethod" type="hidden" name="AuthMethod" value="%AuthMethod%" />
            <input id="context" type="hidden" name="Context" value="%Context%" />
            <!-- End inputs are required by the presentation framework. -->
            <p id="pageIntroductionText">This content is provided by the MFA sample adapter. Challenge inputs should be presented below.</p>
            <label for="challengeQuestionInput" class="block">Question text</label>
            <input id="challengeQuestionInput" name="ChallengeQuestionAnswer" type="text" value="" class="text" placeholder="Answer placeholder" />
            <div id="submissionArea" class="submitMargin">
                <input id="submitButton" type="submit" name="Submit" value="Submit" onclick="return AuthPage.submitAnswer()"/>
            </div>
        </form>
        <div id="intro" class="groupMargin">
            <p id="supportEmail">Support information</p>
        </div>
        <script type="text/javascript" language="JavaScript">
            //<![CDATA[
            function AuthPage() { }
            AuthPage.submitAnswer = function () { return true; };
            //]]>
        </script>
    </div>
    
  14. 次に、[プロジェクト>]、[コンポーネントの追加]、[リソース] ファイルの順に選択します。リソースファイルに名前を付け、[追加] をクリックします

    Screenshot of the Add New Item dialog box showing Resource File selected.

  15. 次に、Resources.resx ファイル内で、[リソースの追加] を選択し、既存のファイルを追加します。 前の手順で保存したテキストファイル (html フラグメントを含む) に移動します。

    リソースファイル (.resx ファイル) 名のプレフィックスとリソース自体の名前によって、新しいリソースの名前が GetFormHtml コードによって正しく解決されることを確認します:

    public string GetFormHtml(int lcid)
    {
        string htmlTemplate = Resources.MfaFormHtml; //Resxfilename.resourcename
        return htmlTemplate;
    }
    

これで、をビルドできるようになります。

アダプターを作成する

このアダプターは、Windows で GAC にインストールできる厳密に名前が付けられた .NET アセンブリに組み込む必要があります。 これを Visual Studio プロジェクトで実現するには、次の手順を実行します:

  1. ソリューション エクスプローラーでプロジェクト名を右クリックし、[プロパティ] をクリックします。

  2. [署名] タブで、[アセンブリの署名] をオンにし、 [厳密な名前のキーファイルを選択:] 下で [<新規作成 >] を選択します。キー ファイル名とパスワードを入力し [OK] をクリックします。 次に、[アセンブリの署名] がチェックされ、[遅延署名のみ] がオフになっていることを確認します。 プロパティの [署名] ページは次のようになります:

    build the provider

  3. 次にソリューションをビルドします。

アダプターを AD FS のテスト コンピューターに展開する

外部プロバイダーを AD FS によって呼び出すには、その前にシステムに登録する必要があります。 アダプター プロバイダーは、GAC へのインストールなど、必要なインストール操作を実行するインストーラーを提供する必要があります。また、インストーラーは AD FS での登録をサポートしている必要があります。 これが行わない場合は、管理者は以下の Windows PowerShell の手順を実行する必要があります。 これらの手順は、テストとデバッグを有効にするためにラボで使用できます。

テスト用 AD FS コンピューターを準備する

ファイルをコピーして GAC に追加します。

  1. Windows Server 2012 R2 コンピューターまたは仮想マシンがあることを確認します。

  2. AD FS の役割サービスをインストールし、少なくとも 1 つのノードを含むファームを構成します。

    ラボ環境でフェデレーション サーバーをセットアップする詳細な手順については、「Windows Server 2012 R2 AD FS 展開ガイド」を参照してください。

  3. Gacutil.exe ツールをサーバーにコピーします。

    Gacutil.exe は、Windows 8 マシン上の% homedrive% Program Files (x86) Microsoft sdkswindowsv 8.0 abinnetfx 4.0 ツールにあります。 gacutil.exe ファイル自体と、1033En-us、および NETFX 4.0 ツールの場所の下にあるその他のローカライズされたリソース フォルダーが必要です。

  4. プロバイダー ファイル (1 つ以上の厳密な名前で署名された .dll ファイル) を gacutil.exe と同じフォルダーの場所にコピーします (場所は便宜上)

  5. ファーム内の各 AD FS フェデレーション サーバーの GAC に .dll ファイルを追加します:

    例: コマンドライン ツール GACutil.exe を使用して、GAC に dll を追加します: C:>.gacutil.exe /if .<yourdllname>.dll

    GAC に結果のエントリを表示するには、次のようにします: C:>.gacutil.exe /l <yourassemblyname>

AD FS にプロバイダーを登録する

上記の前提条件が満たされたら、フェデレーション サーバーで Windows PowerShell コマンド ウィンドウを開き、次のコマンドを入力します (Windows Internal Database を使用するフェデレーション サーバー ファームを使用している場合は、ファームのプライマリ フェデレーション サーバーで次のコマンドを実行する必要があります):

  1. Register-AdfsAuthenticationProvider –TypeName YourTypeName –Name “AnyNameYouWish” [–ConfigurationFilePath (optional)]

    ここで、YourTypeName は .NET の厳密な型名です: "YourDefaultNamespace.YourIAuthenticationAdapterImplementationClassName, YourAssemblyName, Version=YourAssemblyVersion, Culture=neutral, PublicKeyToken=YourPublicKeyTokenValue, processorArchitecture=MSIL"

    これにより、外部プロバイダーが AD FS に登録されます。上記の AnyNameYouWish で指定した名前が使用されます。

  2. (たとえば、Windows Services スナップインを使用して) AD FS サービスを再起動します。

  3. コマンド Get-AdfsAuthenticationProvider を実行します。

    これにより、プロバイダーがシステムのプロバイダーの 1 つとして表示されます。

    例:

    $typeName = "MFAadapter.MyAdapter, MFAadapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e675eb33c62805a0, processorArchitecture=MSIL”
    Register-AdfsAuthenticationProvider -TypeName $typeName -Name “MyMFAAdapter”
    net stop adfssrv
    net start adfssrv
    

    AD FS 環境でデバイス登録サービスが有効になっている場合は、次の PowerShell コマンドも実行します: net start drs

    登録されているプロバイダーを確認するには、次の PowerShell コマンドを使用します: Get-AdfsAuthenticationProvider

    これにより、プロバイダーがシステムのプロバイダーの 1 つとして表示されます。

アダプターを呼び出す AD FS 認証ポリシーを作成する

AD FS 管理スナップインを使用して認証ポリシーを作成する

  1. (サーバーマネージャーの [ツール] メニューから) AD FS 管理スナップインを開きます。

  2. 認証ポリシーをクリックします。

  3. 中央のウィンドウで、多要素認証 の下の グローバル設定右側にある 編集 リンクをクリックします。

  4. ページの下部にある [追加の認証方法の選択] で、プロバイダーの AdminName のチェックボックスをオンにします。 [適用] をクリックします。

  5. 例えば、アダプターを使用して MFA を呼び出す "トリガー" を提供するには、[場所] で、 エクストラネットイントラネットの両方を確認します。 [OK] をクリックします。 (証明書利用者ごとにトリガーを構成するには、以下の「Windows PowerShell を使用した認証ポリシーの作成」を参照してください)

  6. 次のコマンドを使用して結果を確認します:

    最初に Get-AdfsGlobalAuthenticationPolicy を使用します。 プロバイダー名は、AdditionalAuthenticationProvider 値の 1 つとして表示されます。

    次に Get-AdfsAdditionalAuthenticationRule を使用します。 管理者 UI でポリシーを選択した結果として、エクストラネットとイントラネットのルールが構成されていることを確認します。

Windows PowerShell を使用した認証ポリシーを作成する

  1. 最初に、グローバルポリシーでプロバイダーを有効にします:

    Set-AdfsGlobalAuthenticationPolicy -AdditionalAuthenticationProvider “YourAuthProviderName”`
    

    注意

    AdditionalAuthenticationProvider パラメーターに指定された値は、上記の Register-AdfsAuthenticationProvider コマンドレットの "Name" パラメーターに指定した値と、Get-AdfsAuthenticationProvider コマンドレットの出力の "Name" プロパティに対応していることに注意してください。

    Set-AdfsGlobalAuthenticationPolicy –AdditionalAuthenticationProvider “MyMFAAdapter”`
    
  2. 次に、グローバルまたは証明書利用者固有のルールを構成して、MFA をトリガーします:

    例 1: 外部要求に対して MFA を要求するグローバル ルールを作成するには、次のようにします:

    Set-AdfsAdditionalAuthenticationRule –AdditionalAuthenticationRules 'c:[type == "http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork", value == "false"] => issue(type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod", value = "http://schemas.microsoft.com/claims/multipleauthn" );'
    

    例 2: 特定の証明書利用者への外部要求に対して MFA を要求する MFA ルールを作成するには。 (注: 個々のプロバイダーは Windows Server 2012 R2 の AD FS の個々の証明書利用者に接続できないことに注意してください)。

    $rp = Get-AdfsRelyingPartyTrust –Name <Relying Party Name>
    Set-AdfsRelyingPartyTrust –TargetRelyingParty $rp –AdditionalAuthenticationRules 'c:[type == "http://schemas.microsoft.com/ws/2012/01/insidecorporatenetwork", value == "false"] => issue(type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod", value = "http://schemas.microsoft.com/claims/multipleauthn" );'
    

アダプターを使用して MFA で認証する

最後に、次の手順を実行してアダプターをテストします:

  1. AD FS グローバル プライマリ認証の種類が、エクストラネットとイントラネットの両方のフォーム認証として構成されていることを確認します (これにより、デモを特定のユーザーとして簡単に認証できるようになります)

    1. AD FS スナップインの [認証ポリシー] の [プライマリ認証] 領域で、[グローバル設定] の横にある [編集] をクリックします。

      1. または、多要素ポリシー UI の [プライマリ] タブをクリックします。
  2. エクストラネットとイントラネットの両方の認証方法で、 フォーム認証 が唯一のオプションとして選択されていることを確認します。 [OK] をクリックします。

  3. IDP によって開始されたサインオン html ページ (https:// < fsname > /adfs/ls/idpinitiatedsignon.htm) を開き、テスト環境で有効な AD ユーザーとしてサインインします。

  4. プライマリ認証の資格情報を入力してください。

  5. チャレンジの質問の例が表示された MFA フォーム ページが表示されます。

    複数のアダプターが構成されている場合は、上記のフレンドリ名を使用して MFA の選択ページが表示されます。

    Screenshot of the the M F A forms page with example challenge questions.

    Screenshot of the the M F A choice page.

これで、インターフェイスを実用的に実装できるようになり、モデルの動作についての知識が得られました。 BeginAuthentication と TryEndAuthentication にブレーク ポイントを設定するための追加の例として試してみることができます。 ユーザーが最初に MFA フォームに入力したときに BeginAuthentication が実行され、フォーム送信のたびに TryEndAuthentication がトリガーされることを確認してください。

認証が成功するようにアダプターを更新する

しかし、お待ちください。アダプターの例は正常に認証されません。 これは、コード内に TryEndAuthentication に対して null を返すものがないためです。

上記の手順を完了することで基本的なアダプターの実装が作成され、AD FS サーバーに追加されました。 MFA フォーム ページは取得できますが、TryEndAuthentication 実装に適切なロジックがまだ配置されていないため、まだ認証できません。 それを追加しましょう。

TryEndAuthentication の実装を思い出してください:

public IAdapterPresentation TryEndAuthentication(IAuthenticationContext authContext, IProofData proofData, HttpListenerRequest request, out Claim[] outgoingClaims)
{
    //return new instance of IAdapterPresentationForm derived class
    outgoingClaims = new Claim[0];
    return new MyPresentationForm();
}

常に MyPresentationForm () を返さないように更新しましょう。 これには、クラス内に 1 つの単純なユーティリティ メソッドを作成できます:

static bool ValidateProofData(IProofData proofData, IAuthenticationContext authContext)
{
    if (proofData == null || proofData.Properties == null || !proofData.Properties.ContainsKey("ChallengeQuestionAnswer"))
    {
        throw new ExternalAuthenticationException("Error - no answer found", authContext);
    }

    if ((string)proofData.Properties["ChallengeQuestionAnswer"] == "adfabric")
    {
        return true;
    }
    else
    {
        return false;
    }
}

次に、次のように TryEndAuthentication を更新します:

public IAdapterPresentation TryEndAuthentication(IAuthenticationContext authContext, IProofData proofData, HttpListenerRequest request, out Claim[] outgoingClaims)
{
    outgoingClaims = new Claim[0];
    if (ValidateProofData(proofData, authContext))
    {
        //authn complete - return authn method
        outgoingClaims = new[]
        {
            // Return the required authentication method claim, indicating the particulate authentication method used.
            new Claim( "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod", "http://example.com/myauthenticationmethod1" )
        };
        return null;
    }
    else
    {
        //authentication not complete - return new instance of IAdapterPresentationForm derived class
        return new MyPresentationForm();
    }
}

次に、[テスト] ボックスでアダプターを更新する必要があります。 最初に AD FS ポリシーを元に戻し、次に AD FS から登録を解除してから AD FS を再起動し、GAC から .dll を削除して新しい .dll を GAC に追加、AD FS に再起動してから AD FS に再登録し、AD FS ポリシーを再構成する必要があります。

テスト用 AD FS コンピューターで更新されたアダプターを展開して構成する

AD FS ポリシーをクリアする

次に示すように、MFA UI で MFA 関連のすべてのチェックボックスをオフにし、[OK] をクリックします。

clear policy

プロバイダーの登録解除 (Windows PowerShell)

PS C:> Unregister-AdfsAuthenticationProvider –Name “YourAuthProviderName”

例:PS C:> Unregister-AdfsAuthenticationProvider –Name “MyMFAAdapter”

"Name" に渡す値は、Register-AdfsAuthenticationProvider コマンドレットに指定した "Name" と同じ値です。 また、Get-AdfsAuthenticationProvider から出力される "Name" プロパティでもあります。

プロバイダーの登録を解除する前に、AdfsGlobalAuthenticationPolicy からプロバイダーを削除する必要があります (AD FS 管理スナップインでチェックインしたチェックボックスをオフにするか、Windows PowerShell を使用します)。

この操作の後に、AD FS サービスを再起動する必要があります。

GAC からのアセンブリの削除

  1. まず、次のコマンドを使用して、エントリの完全修飾された厳密な名前を検索します: C:>.gacutil.exe /l <yourAdapterAssemblyName>

    例:C:>.gacutil.exe /l mfaadapter

  2. 次に、次のコマンドを使用して GAC から削除します: .gacutil /u “<output from the above command>”

    例:C:>.gacutil /u “mfaadapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e675eb33c62805a0, processorArchitecture=MSIL”

更新されたアセンブリを GAC に追加する

更新された .dll を最初にローカルに貼り付けるようにします。 C:>.gacutil.exe /if .MFAAdapter.dll

GAC でのアセンブリの表示 (コマンドライン)

C:> .gacutil.exe /l mfaadapter

AD FS にプロバイダーを登録する

  1. PS C:>$typeName = "MFAadapter.MyAdapter, MFAadapter, Version=1.0.0.1, Culture=neutral, PublicKeyToken=e675eb33c62805a0, processorArchitecture=MSIL”

  2. PS C:>Register-AdfsAuthenticationProvider -TypeName $typeName -Name “MyMFAAdapter1”

  3. AD FS サービスを再起動します。

AD FS 管理スナップインを使用して認証ポリシーを作成する

  1. (サーバーマネージャーの [ツール] メニューから) AD FS 管理スナップインを開きます。

  2. 認証ポリシーをクリックします。

  3. 多要素認証 の下の グローバル設定右側にある 編集 リンクをクリックします。

  4. [追加の認証方法の選択] で、プロバイダーの AdminName のチェックボックスをオンにします。 [適用] をクリックします。

  5. 例えば、アダプターを使用して MFA を呼び出す "トリガー" を提供するには、[場所] で、 エクストラネットイントラネットの両方を確認します。 [OK] をクリックします。

アダプターを使用して MFA で認証する

最後に、次の手順を実行してアダプターをテストします:

  1. AD FS グローバル プライマリ認証の種類が、エクストラネットとイントラネットの両方のフォーム認証として構成されていることを確認します (これにより、デモを特定のユーザーとして簡単に認証できるようになります)。

    1. AD FS 管理スナップインの [認証ポリシー] の [プライマリ認証] 領域で、[グローバル設定] の横にある [編集] をクリックします。

      1. または、多要素ポリシー UI の [プライマリ] タブをクリックします。
  2. エクストラネットイントラネットの両方の認証方法で、 フォーム認証 が唯一のオプションとして選択されていることを確認します。 [OK] をクリックします。

  3. IDP によって開始されたサインオン html ページ (https:// < fsname > /adfs/ls/idpinitiatedsignon.htm) を開き、テスト環境で有効な AD ユーザーとしてサインインします。

  4. プライマリ認証の資格情報を入力してください。

  5. チャレンジのテキストの例が表示された MFA フォーム ページが表示されます。

    1. 複数のアダプターが構成されている場合は、フレンドリ名を使用して MFA の選択ページが表示されます。

MFA 認証ページで adfabric を入力すると、サインインに成功したと表示されます。

Screenshot of the M F A forms page with example challenge text.

Screenshot of the M F A successful sign in page.

参照

その他の参照情報

追加の認証方法

追加の多要素認証による個人情報アプリケーションのリスク管理