Hello-
I need help in understanding some things that I am confused about. I am authenticating users using advanced security, using an LDAP directory server to check user name and passwords.
So far I have it so when you access any file in the directory, the application.cfm kicks in and verifies a user. This works fine.
The login in page is actually in the application.cfm. What do I need to do to trigger the login screen to appear.
Code is below. Thanks for your help.
Matt
logout.cfm.
---------------------------------------------------------------------
<CFSET StructClear(Session)>
<cflocation addtoken="Yes" url="index.cfm?logout=yes">
----------------------------------------------------
Application.cfm
-------------------------------------------------
<cfapplication name="pw"
clientmanagement="Yes"
applicationtimeout="#CreateTime(0, 0, 1)#"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#CreateTime(0, 0, 1)#" >
<CFIF not IsAuthenticated()>
<!--- The user is not authenticated --->
<CFSET showLogin = "No">
<CFIF IsDefined("form.username"
and
IsDefined("form.password"
>
<cfset session.username="#form.username#">
<cfset session.password="#form.password#">
<!--- The login form was submitted --->
<CFTRY>
<cfauthenticate setcookie="Yes"
throwonfailure="Yes"
securitycontext="PageWorkers"
username="#form.username#"
password="#form.password#">
<CFCATCH TYPE="security">
<!--- Security error in login occurred,
show login again --->
<H3>Invalid Login</H3>
<CFSET showLogin = "Yes">
</CFCATCH>
</CFTRY>
<CFELSE>
<!--- The login was not detected --->
<CFSET showLogin = "Yes">
</CFIF>
<CFIF showLogin>
<!--- Recreate the url used to call this template --->
<CFSET url = "#cgi.script_name#">
<CFIF cgi.query_string is not "">
<CFSET url = url & "?#cgi.query_string#">
</CFIF>
<!--- Populate the login with the recreated url --->
<CFOUTPUT>
<FORM ACTION="#url#" METHOD="Post">
<TABLE>
<TR>
<TD>username:</TD>
<TD><INPUT TYPE="text" NAME="username"></TD>
</TR>
<TR>
<TD>password:</TD>
<TD><INPUT TYPE="password" NAME="password"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Login">
</FORM>
</CFOUTPUT>
<CFABORT>
</CFIF>
</CFIF>
<!--- Log the user out. --->
<CFIF IsDefined("URL.Logout"
>
<P>
Logging you off.
<P>
<!--- Kill the app --->
<CFAPPLICATION NAME="pw"
SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(0,0,0,0)#">
<meta http-equiv="REFRESH" content="1; url=index.cfm">
<CFABORT>
</CFIF>
I need help in understanding some things that I am confused about. I am authenticating users using advanced security, using an LDAP directory server to check user name and passwords.
So far I have it so when you access any file in the directory, the application.cfm kicks in and verifies a user. This works fine.
The login in page is actually in the application.cfm. What do I need to do to trigger the login screen to appear.
Code is below. Thanks for your help.
Matt
logout.cfm.
---------------------------------------------------------------------
<CFSET StructClear(Session)>
<cflocation addtoken="Yes" url="index.cfm?logout=yes">
----------------------------------------------------
Application.cfm
-------------------------------------------------
<cfapplication name="pw"
clientmanagement="Yes"
applicationtimeout="#CreateTime(0, 0, 1)#"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#CreateTime(0, 0, 1)#" >
<CFIF not IsAuthenticated()>
<!--- The user is not authenticated --->
<CFSET showLogin = "No">
<CFIF IsDefined("form.username"
IsDefined("form.password"
<cfset session.username="#form.username#">
<cfset session.password="#form.password#">
<!--- The login form was submitted --->
<CFTRY>
<cfauthenticate setcookie="Yes"
throwonfailure="Yes"
securitycontext="PageWorkers"
username="#form.username#"
password="#form.password#">
<CFCATCH TYPE="security">
<!--- Security error in login occurred,
show login again --->
<H3>Invalid Login</H3>
<CFSET showLogin = "Yes">
</CFCATCH>
</CFTRY>
<CFELSE>
<!--- The login was not detected --->
<CFSET showLogin = "Yes">
</CFIF>
<CFIF showLogin>
<!--- Recreate the url used to call this template --->
<CFSET url = "#cgi.script_name#">
<CFIF cgi.query_string is not "">
<CFSET url = url & "?#cgi.query_string#">
</CFIF>
<!--- Populate the login with the recreated url --->
<CFOUTPUT>
<FORM ACTION="#url#" METHOD="Post">
<TABLE>
<TR>
<TD>username:</TD>
<TD><INPUT TYPE="text" NAME="username"></TD>
</TR>
<TR>
<TD>password:</TD>
<TD><INPUT TYPE="password" NAME="password"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" VALUE="Login">
</FORM>
</CFOUTPUT>
<CFABORT>
</CFIF>
</CFIF>
<!--- Log the user out. --->
<CFIF IsDefined("URL.Logout"
<P>
Logging you off.
<P>
<!--- Kill the app --->
<CFAPPLICATION NAME="pw"
SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(0,0,0,0)#">
<meta http-equiv="REFRESH" content="1; url=index.cfm">
<CFABORT>
</CFIF>