<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFNTAUTHENTICATE</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="説明">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFNTAUTHENTICATE</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">説明</span>
<p>
ColdFusion サーバーが稼動している Windows NT ドメインに対してユーザー名とパスワードを認証し、必要に応じてユーザーのグループを取り出します。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">カテゴリ</span>
<p>
セキュリティタグ
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</span><pre>&lt;cfNTauthenticate
username=&quot;username&quot; 
password=&quot;password&quot; 
domain=&quot;nt_domain&quot; 
result=&quot;result variable&quot;
listGroups = &quot;yes&quot;、&quot;no&quot;
throwOnError = &quot;yes&quot;、&quot;no&quot;&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">関連項目</span>
<p>
cflogin、cfloginuser、IsUserInRole、GetAuthUser
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">ヒストリ</span>
<p>
ColdFusion&#160;MX&#160;7: このタグが追加されました。
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">使用方法</span>
<p>
この関数を使用して、Windows NT ドメインに対してユーザーを認証し、必要に応じてユーザーのグループを取得します。この関数は、Microsoft Active Directory ディレクトリサービスでは機能せず、UNIX システムおよび Linux システムでは何も実行しません。通常は、後の例に示すように、このタグを cflogin タグ内で使用して cfloginuser タグに対してユーザーを認証します。 
</p>
<table>
  <tr valign="top">
    <td width="30"><strong>メモ: </strong></td>
    <td>ColdFusion は、指定されたドメイン内の他のユーザーを認証する権限があるユーザーとして実行する必要があります。</td>
  </tr>
</table>
<p>
result 属性で指定された構造体には、次の情報が格納されています。
</p>

<p>

</p>

<p>
このタグは、認証の処理について、ステータス確認および例外処理という 2 つのモデルを提供します。throwOnError 属性が No の場合は、結果変数の auth フィールドと status フィールドを使用して、ユーザーが認証されたかどうかを確認します。認証されなかった場合は、認証失敗の原因を確認します。throwOnError 属性が Yes の場合、ユーザーが無効のときに ColdFusion では例外エラーが発生します。その場合は、try/catch エラー処理を使用します。catch ブロックでは、あらゆる認証の失敗を処理します。
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">例</span>
<p>
次の例では、auth フィールドと status フィールドを使用して、ユーザーが認証されるかどうかおよびエラーが発生するかどうかを確認します。同じディレクトリに置いた次の 3 つのファイルで構成されています。
</p>
<ul>

<li>メインの cfntauthexample.cfm ページ。ユーザーが認証された場合にそのユーザー名を表示します。ログアウトリンクを含んでいます。</li>

<li>ログインフォームページ。ユーザーがログインしていない場合に表示されます。</li>

<li>Application.cfm ページ。ログイン、認証、およびログアウトのすべての処理コードを含んでいます。</li>
</ul>

<p>
ログイン処理の詳細については、『ColdFusion MX 開発ガイド』を参照してください。この例の詳細については、コード内のコメントを参照してください。
</p>

<p>
次のページを cfntauthenticateexample.cfm として保存します。この例を実行するには、ブラウザまたは IDE からこのページをリクエストします。
</p>
<pre>&lt;!--- Application.cfm ページです。ユーザーがこのページをリクエストする
   たびに処理されます。最初にログインする必要があります。 ---&gt;
&lt;cfoutput&gt;
   &lt;h3&gt;Welcome #GetAuthUser()#&lt;/h3&gt;
   &lt;!--- ユーザーログアウトへのリンクです。 ---&gt;
   &lt;a href=&quot;#CGI.script_name#?logout=Yes&quot;&gt;Log Out&lt;/a&gt; 
&lt;/cfoutput&gt;
</pre>
<p>
次のページを loginform.cfm として保存します。
</p>
<pre>&lt;!--- ログインのリクエストがあったページに返される、シンプルなログインフォーム
   です。 ---&gt;
&lt;H2&gt;ログインしてください&lt;/H2&gt;
&lt;cfform action=&quot;#CGI.script_name#&quot;&gt;
   &lt;!--- j_username と j_password は cflogin タグ変数の挿入を行う特別な
      名前です。 ---&gt;
   ユーザー名 : &lt;cfinput type=&quot;text&quot; name=&quot;j_username&quot; value=&quot;cfqa_user1&quot;
      required=&quot;Yes&quot;&gt;&lt;br&gt;
   パスワード : &lt;cfinput type=&quot;password&quot; name=&quot;j_password&quot; value=&quot;cfqa_user1&quot;
      required=&quot;Yes&quot;&gt;&lt;br&gt;
   ドメイン : &lt;cfinput type=&quot;text&quot; name=&quot;domain&quot; value=&quot;rnd&quot; required=&quot;Yes&quot;&gt;&lt;br&gt;
   &lt;input type=&quot;submit&quot; value=&quot;ログイン&quot;&gt;
&lt;/cfform&gt;
</pre>
<p>
次のページを Application.cfm として保存します。
</p>
<pre>&lt;!--- ユーザーがログアウトリンクをクリックしたことに応答してこのページが実行されている場合、
      ユーザーをログアウトします。cflogin タグのコードが実行されます。 ---&gt;
&lt;cfif IsDefined(&quot;URL.logout&quot;) AND URL.logout&gt;
   &lt;cflogout&gt;
&lt;/cfif&gt;

&lt;!--- ユーザーがログインしていない場合に限り、cflogin 本文のコードが実行されます。 ---&gt;
&lt;cflogin&gt;
   &lt;!--- ログイン証明情報が使用可能な場合に限り、cflogin 変数が存在します。 ---&gt;
   &lt;cfif NOT IsDefined(&quot;cflogin&quot;)&gt;
      &lt;!--- ログインのリクエストがあったページに返されるログインフォームを
      示します。このページの残りの部分は処理しません。 ---&gt;
      &lt;cfinclude template=&quot;loginform.cfm&quot;&gt;
      &lt;cfabort&gt;
   &lt;cfelse&gt;
      &lt;!--- フォームで送信されたユーザー名とパスワードから前後のスペースを
      削除します。 ---&gt;
      &lt;cfset theusername=trim(form.j_username)&gt;
      &lt;cfset thepassword=trim(form.j_password)&gt;
      &lt;cfset thedomain=trim(form.domain)&gt;
      &lt;cfntauthenticate username=&quot;#theusername#&quot; password=&quot;#thepassword#&quot;
         domain=&quot;#thedomain#&quot; result=&quot;authresult&quot; listgroups=&quot;yes&quot;&gt;
      &lt;!--- ユーザーが認証されると、authresult.auth は true になります。 ---&gt;
      &lt;cfif authresult.auth&gt;
         &lt;!--- ユーザーを ColdFusion にログインし、ロールをユーザーのグループに設定します。 ---&gt;
         &lt;cfloginuser name=&quot;#theusername#&quot; password=&quot;#thepassword#&quot;
            roles=&quot;authresult.groups&quot;&gt;
      &lt;cfelse&gt;
         &lt;!--- ユーザーは認証されませんでした。 
               エラーメッセージとログインフォームが表示されます。 ---&gt;
         &lt;cfoutput&gt;
            &lt;cfif authresult.status IS &quot;AuthenticationFailure&quot;&gt;
               &lt;!--- ユーザーは有効ですが、パスワードは無効です。 ---&gt;
               &lt;H2&gt;#theusername# のパスワードが正しくありません&lt;br&gt;
                  もう一度入力してください&lt;/H2&gt;
            &lt;cfelse&gt;
               &lt;!--- もう 1 つのステータス値、無効なユーザー名があります。 ---&gt;
               &lt;H2&gt;ユーザー名 #theusername# は無効です&lt;br&gt;
                  もう一度入力してください&lt;/H2&gt;
            &lt;/cfif&gt;
         &lt;/cfoutput&gt;
         &lt;cfinclude template=&quot;loginform.cfm&quot;&gt;
         &lt;cfabort&gt;
      &lt;/cfif&gt;
   &lt;/cfif&gt;
&lt;/cflogin&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="NAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">NAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ユーザーのログイン名です。</p>

  </td>
  </tr>
  </table>
</div>
<div id="PASSWORD">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">PASSWORD</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ユーザーのパスワードです。</p>

  </td>
  </tr>
  </table>
</div>
<div id="DOMAIN">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DOMAIN</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ユーザーを認証する対象のドメインです。ColdFusion J2EE サーバーはこのドメインで稼動している必要があります。</p>

  </td>
  </tr>
  </table>
</div>
<div id="RESULT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">RESULT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "cfntauthenticate"


<p>結果を返す変数の名前です。</p>

  </td>
  </tr>
  </table>
</div>
<div id="LISTGROUPS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">LISTGROUPS</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "No"


<p>ユーザーのグループをカンマで区切りで示すリストを結果の構造体に含めるかどうかを指定するブール値です。</p>

  </td>
  </tr>
  </table>
</div>
<div id="THROWONERROR">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">THROWONERROR</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">

<strong>Default value:</strong> "No"


<p>認証が失敗したときに例外が発生するかどうかを指定するブール値です。この属性が Yes の場合、ユーザー名またはパスワードが無効のときは ColdFusion ではエラーが発生します。このアプリケーションでは、try/catch ブロックまたは ColdFusion エラーハンドラページでこうしたエラーを処理する必要があります。</p>

  </td>
  </tr>
  </table>
</div>
<div id="AUTH">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">AUTH</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">ユーザーを認証するかどうかを指定します。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">
  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Yes</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">
  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">No</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">


  </td>
  </tr>
  </table>
</div>
<div id="GROUPS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">GROUPS</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">指定されたドメイン内のユーザーのグループを示すカンマ区切りのリストです。listGroups 属性が Yes の場合、構造体にはこのフィールドだけが含まれます。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">


  </td>
  </tr>
  </table>
</div>
<div id="NAME">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">NAME</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">ユーザー名です。タグの name 属性と同じです。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">


  </td>
  </tr>
  </table>
</div>
<div id="STATUS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">STATUS</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">認証のステータスです。次のいずれかです。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">
  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">success</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">
  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">UserNotInDirFailure: ユーザーはディレクトリに存在しません。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">
  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">AuthenticationFailure: ユーザーはディレクトリに存在しますが、パスワードが無効です。</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">


  </td>
  </tr>
  </table>
</div>

  </body>
</html>
