Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with application.cfm

Status
Not open for further replies.

mattyb

Programmer
Aug 3, 2000
12
US
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=&quot;Yes&quot; url=&quot;index.cfm?logout=yes&quot;>
----------------------------------------------------

Application.cfm
-------------------------------------------------
<cfapplication name=&quot;pw&quot;
clientmanagement=&quot;Yes&quot;
applicationtimeout=&quot;#CreateTime(0, 0, 1)#&quot;
sessionmanagement=&quot;Yes&quot;
setclientcookies=&quot;Yes&quot;
sessiontimeout=&quot;#CreateTime(0, 0, 1)#&quot; >

<CFIF not IsAuthenticated()>
<!--- The user is not authenticated --->

<CFSET showLogin = &quot;No&quot;>
<CFIF IsDefined(&quot;form.username&quot;) and
IsDefined(&quot;form.password&quot;)>
<cfset session.username=&quot;#form.username#&quot;>
<cfset session.password=&quot;#form.password#&quot;>
<!--- The login form was submitted --->
<CFTRY>
<cfauthenticate setcookie=&quot;Yes&quot;
throwonfailure=&quot;Yes&quot;
securitycontext=&quot;PageWorkers&quot;
username=&quot;#form.username#&quot;
password=&quot;#form.password#&quot;>

<CFCATCH TYPE=&quot;security&quot;>

<!--- Security error in login occurred,
show login again --->
<H3>Invalid Login</H3>
<CFSET showLogin = &quot;Yes&quot;>
</CFCATCH>
</CFTRY>

<CFELSE>
<!--- The login was not detected --->
<CFSET showLogin = &quot;Yes&quot;>
</CFIF>

<CFIF showLogin>
<!--- Recreate the url used to call this template --->
<CFSET url = &quot;#cgi.script_name#&quot;>
<CFIF cgi.query_string is not &quot;&quot;>
<CFSET url = url &amp; &quot;?#cgi.query_string#&quot;>
</CFIF>

<!--- Populate the login with the recreated url --->

<CFOUTPUT>
<FORM ACTION=&quot;#url#&quot; METHOD=&quot;Post&quot;>
<TABLE>
<TR>
<TD>username:</TD>
<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;username&quot;></TD>
</TR>

<TR>
<TD>password:</TD>
<TD><INPUT TYPE=&quot;password&quot; NAME=&quot;password&quot;></TD>
</TR>
</TABLE>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Login&quot;>

</FORM>



</CFOUTPUT>
<CFABORT>
</CFIF>

</CFIF>





<!--- Log the user out. --->
<CFIF IsDefined(&quot;URL.Logout&quot;)>
<P>
Logging you off.
<P>
<!--- Kill the app --->
<CFAPPLICATION NAME=&quot;pw&quot;
SESSIONMANAGEMENT=&quot;Yes&quot;
SESSIONTIMEOUT=&quot;#CreateTimeSpan(0,0,0,0)#&quot;>
<meta http-equiv=&quot;REFRESH&quot; content=&quot;1; url=index.cfm&quot;>
<CFABORT>
</CFIF>

 
&quot;What do I need to do to trigger the login screen to appear.&quot; --> you mean, another one that the one that already appears ?? coz you've got one, a very simple form with username and password prompt ...
so if it was the question, just replace the part between <cfif showlogin>...</cfif> with <cflocation=&quot;your_login_page&quot;>
but it's not as smart as what is here already, because it will direct the user to the login page, no matter where he was or wanted to go - the example in the application file let the user stay where he is.
 
iza-

Thanks for your help. So what I actually need to do is to create a new login page? Can you use CFapplication to verify the login on an action page? Would I set the form action on the login page to point to a page like form_action.cfm, and have that contain the CFapplication, or would I verify it using cfladp?

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top