Whatever message this page gives is out now! Go check it out!
<cfNTauthenticate
domain="NT domain"
password="password"
username="user name"
listGroups = "yes|no"
result="result variable"
throwOnError = "yes|no">Attribute | Req/Opt | Default | Description |
domain | Required | Domain against which to authenticate the user. The ColdFusion J2EE server must be running on this domain. | |
password | Required | User's password. | |
username | Required | User's login name. | |
listGroups | Optional | No | Boolean value that specifies whether to include a comma-delimited list of the user's groups in the result structure. |
result | Optional | cfntauthenticate | Name of the variable in which to return the results. |
throwOnError | Optional | no | Boolean value that specifies whether to throw an exception if the validation fails. If this attribute is yes, ColdFusion throws an error if the username or password is invalid; the application must handle such errors in a try/catch block or ColdFusion error handler page. |
Field | Value |
auth | Whether the user is authenticated:
|
groups | A comma-delimited list of the user's groups in the specified domain. The structure includes this field only if the listGroups attribute is yes. |
name | The user name; equals the tag's username attribute. |
status | The authentication status. One of the following:
|
<!--- The Application.cfm page, which is processed each time a user
requests this page, ensures that you log in first. --->
<cfoutput>
<h3>Welcome #GetAuthUser()#</h3>
<!--- A link to log out the user. --->
<a href="#CGI.script_name#?logout=Yes">Log Out</a>
</cfoutput><!--- A simple login form that posts back to the page whose request initiated the login. --->
<h2>Please Log In</h2>
<cfform action="#CGI.script_name#">
<!--- j_username and j_password are special names that populate cflogin tag
variables. --->
User Name: <cfinput type="text" name="j_username" value="cfqa_user1" required="Yes"><br>
Password: <cfinput type="password" name="j_password" value="cfqa_user1"
required="Yes"><br>
Domain: <cfinput type="text" name="domain" value="rnd" required="Yes"><br>
<input type="submit" value="Log In">
</cfform><!--- If this page is executing in response to the user clicking a logout link,
log out the user. The cflogin tag code will then run. --->
<cfif IsDefined("URL.logout") AND URL.logout>
<cflogout>
</cfif>
<!--- The cflogin body code runs only if a user is not logged in. --->
<cflogin>
<!--- cflogin variable exists only if login credentials are available. --->
<cfif NOT IsDefined("cflogin")>
<!--- Show a login form that posts back to the page whose request
initiated the login, and do not process the rest of this page. --->
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<!--- Trim any leading or trailing spaces from the username and password
submitted by the form. --->
<cfset theusername=trim(form.j_username)>
<cfset thepassword=trim(form.j_password)>
<cfset thedomain=trim(form.domain)>
<cfntauthenticate username="#theusername#" password="#thepassword#"
domain="#thedomain#" result="authresult" listgroups="yes">
<!--- authresult.auth is True if the user is authenticated. --->
<cfif authresult.auth>
<!--- Log user in to ColdFusion and set roles to the user's Groups. --->
<cfloginuser name="#theusername#" password="#thepassword#"
roles="#authresult.groups#">
<cfelse>
<!--- The user was not authenticated.
Display an error message and the login form. --->
<cfoutput>
<cfif authresult.status IS "AuthenticationFailure">
<!--- The user is valid, but not the password. --->
<h2>The password for #theusername# is not correct<br>
Please Try again</h2>
<cfelse>
<!--- There is one other status value, invalid user name. --->
<H2>The user name #theusername# is not valid<br>
Please Try again</h2>
</cfif>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
</cfif>
</cfif>
</cflogin>