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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application cfm help

Status
Not open for further replies.

yc1028

MIS
Jul 25, 2003
8
US
HI, i have created this application.cfm inside the cfm i had a function call invoke which allowed me to call my NT secuity for the authentication. Now i need your help, i had a dirtory call admin, whenever user click on any application insdie admin dirtory should go to my application.cfm first but it never happen. can anyone tell me where do i do wrong. here is my code.

------------------------------------------------------------>
<CFAPPLICATION NAME=&quot;PhoneApp&quot;>


<cfset goodlogin=false>

<cfif isDefined(&quot;form.logon&quot;) and len(trim(form.userid)) and len(trim(form.passwd))>
<!--- Note: This is where you would replace the cfinvoke with code from one of
the other security options (Example 1, 3, or 4) --->
<!---Invoke NTSecurity CFC as if it were in the same directory as your calling CFML page.--->

<cfinvoke
component = &quot;NTSecurity&quot;
method = &quot;authenticateAndGetGroups&quot;
domain = &quot;&quot;
userid = &quot;#Form.UserID#&quot;
passwd = &quot;#Form.Passwd#&quot;
returnVariable = &quot;GetUsers&quot;>
<cfscript>
auth = ToString(GetUsers); // GetUsers is either boolean false or a string which is the list of groups valid user belongs to.
if (auth is &quot;false&quot;)
auth = &quot;false&quot;;
else
auth = &quot;true&quot;;
</cfscript>

<cfif isDefined(&quot;GetUsers&quot;) and auth >

<cfif FindNoCase(&quot;PhoneAdmins&quot;, GetUsers)>
<CFSET UROLE = &quot;Admin&quot;>

<cfelse>
<cfset UROLE=&quot;User&quot;>
</cfif>

<CFIF IsUserInRole(&quot;Admin&quot;) or (&quot;User&quot;)>
<cftry>
<cflogin applicationtoken=&quot;PhoneApp&quot; cookiedomain=&quot;&quot;>

<cfloginuser name=&quot;#form.userID#&quot; password=&quot;#form.passwd#&quot; roles=&quot;UROLE&quot;>

<cfcatch type=&quot;security&quot;>
<H3 ALIGN=&quot;center&quot;>Invalid Login</H3>
<cfset showLogin=&quot;yes&quot;>
</cfcatch>
</cftry>
<cfelse>
<cfset showLogin=&quot;yes&quot;>
<cfset goodlogin = true>
</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 & &quot;?#cgi.query_string#&quot;>
</CFIF>

<!--- Populate the login with the recreated url --->
<BODY ONLOAD=&quot;document.forms.Logon.username.focus();&quot;>
<CFOUTPUT>
<FORM ACTION=&quot;#cgi.SCRIPT_NAME#&quot; METHOD=&quot;post&quot; NAME=&quot;Logon&quot;>
</CFOUTPUT>
<TABLE WIDTH=&quot;400&quot; CELLPADDING=&quot;10&quot; ALIGN=&quot;center&quot;>
<TR>
<TD COLSPAN=&quot;2&quot; ALIGN=&quot;center&quot; BGCOLOR=&quot;#003399&quot;><FONT SIZE=&quot;+1&quot; COLOR=&quot;Silver&quot;>LOGIN SCREEN</FONT><BR><FONT COLOR=&quot;White&quot;>(NT UserID and Password)</FONT></TD>
</TR>
<TR>
<TD ALIGN=&quot;right&quot;><B>Username:</B></FONT></TD>
<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;userid&quot; SIZE=&quot;10&quot;></TD>
</TR>
<TR>
<TD ALIGN=&quot;right&quot;><B>Password:</B></FONT></TD>
<TD><INPUT TYPE=&quot;password&quot; NAME=&quot;passwd&quot; SIZE=&quot;20&quot;></TD>
</TR>
<TR>
<TD COLSPAN=&quot;2&quot; ALIGN=&quot;center&quot;><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Logon&quot;></TD>
</TR>
<TR>
<TD COLSPAN=&quot;2&quot; ALIGN=&quot;center&quot; VALIGN=&quot;bottom&quot;><HR></TD>
</TR>
</TABLE>
</FORM>
</BODY>

<CFABORT>
</CFIF>

</cfif>
</cfif>
</cflogin>

thank you
 
If your admin folder is located under your application folder, CF will read the Application.cfm first. But if the admin folder is located somewhere else, the admin folder should have it's own Application.cfm. Never tried this, but maybe you can overcome this problem by setting your web directory mappings.
Good luck.
 
Or use the onrequest.cfm option. CF looks at onrequest in a directory and completes this prior to opening the requested cfm file.

 
Make sure your file is named &quot;Application.cfm&quot; (capital 'A'). Believe it or not, it's case-sensitive on some platforms. Something we've been screaming at Macromedia to fix since before v.4... and here it is almost four years and two major versions later at it's still the case.


-Carl
 
Thanks for all the tip you have given, but it still not quite working. After the Application.cfm my login screen it never show up, instate it will go to my admin page and tell me &quot; I not authiz&quot; so, can any one tell me where did i do wrong on my code. thanks (My admin page)
------------------------------------------------------------
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<HTML>
<HEAD>
<TITLE>Trico Phone Administration Page</TITLE>
</HEAD>

<BODY BACKGROUND=&quot;../../images/phone_bkg.png&quot;>
<CFINCLUDE TEMPLATE=&quot;AdminToolbar.cfm&quot;>
<FONT SIZE=&quot;+2&quot; COLOR=&quot;Navy&quot;>Phone Directory Administration</FONT>
<P>
<CFIF IsUserInRole(&quot;Admin&quot;)>
<TABLE WIDTH=&quot;780&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;20&quot;>
<TR>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;AddEmployee.cfm&quot;><FONT SIZE=&quot;+1&quot;>Add Associate</FONT></A></TD>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;AddResource.cfm&quot;><FONT SIZE=&quot;+1&quot;>Add Resource</FONT></A></TD>
</TR>
<TR>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;AddDept.cfm&quot;><FONT SIZE=&quot;+1&quot;>Add Department</FONT></A></TD>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;SearchDept.cfm&quot;><FONT SIZE=&quot;+1&quot;>Update / Delete Department</FONT></A></TD>
</TR>
<TR>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;AddLoc.cfm&quot;><FONT SIZE=&quot;+1&quot;>Add Location</FONT></A></TD>
<TD ALIGN=&quot;center&quot;><A HREF=&quot;SearchLoc.cfm&quot;><FONT SIZE=&quot;+1&quot;>Update / Delete Location</FONT></A></TD>
</TR>
<TR>
<TD COLSPAN=&quot;2&quot; ALIGN=&quot;center&quot; VALIGN=&quot;bottom&quot;><HR></TD>
</TR>
</TABLE>
<CFELSE>
<H2>You are not authorized to administer the application.</H2>
</CFIF>
</BODY>
</HTML>
------------------------------------------------------------------
Thank you
 
Can you show us your AdminToolbar.cfm? Or maybe the IsUserInRole() function?
 
ok.. here is my admintoolbar code. but i don't think that would be a matter.
------------------------------------------------------------>
<!--- Begin toolbar --->
<TABLE WIDTH=&quot;780&quot; CELLSPACING=&quot;3&quot; CELLPADDING=&quot;3&quot; BGCOLOR=&quot;#003399&quot;>
<TR>
<TD COLSPAN=&quot;3&quot; ALIGN=&quot;center&quot;><FONT SIZE=&quot;+2&quot; COLOR=&quot;Silver&quot;><B>TRICO PHONE DIRECTORY</B></FONT></TD>
</TR>
<TR>
<TD WIDTH=&quot;260&quot; ALIGN=&quot;center&quot;><A HREF=&quot;../PhoneSearch.cfm&quot;><FONT SIZE=&quot;+1&quot; COLOR=&quot;White&quot;><B>Full Search</B></FONT></A></TD>
<TD WIDTH=&quot;260&quot; ALIGN=&quot;center&quot;><A HREF=&quot;../../&quot;><FONT SIZE=&quot;+1&quot; COLOR=&quot;White&quot;><B>RAINweb Home</B></FONT></A></TD>
<TD WIDTH=&quot;260&quot; ALIGN=&quot;center&quot;><A HREF=&quot;AdminMenu.cfm&quot;><FONT SIZE=&quot;+1&quot; COLOR=&quot;White&quot;><B>Administration</B></FONT></A></TD>
</TR>
</TABLE>
<P>
<!--- End toolbar --->
 
Yup. Seems no problem with that. So, I look back to your initial thread, and wonder about the <CFABORT> tag in the bottom part. If I were you, I would try to remove the tag and see what will happen.
 
You also have something of a nesting problem.
Code:
<cfif isDefined(&quot;form.logon&quot;) and len(trim(form.userid)) and len(trim(form.passwd))>
    <cfinvoke ...>
    <cfscript>
	:
    </cfscript>
    <cfif isDefined(&quot;GetUsers&quot;) and auth >
        <cfif FindNoCase(&quot;PhoneAdmins&quot;, GetUsers)>
             :
        <cfelse>
             :
        </cfif>

        <CFIF IsUserInRole(&quot;Admin&quot;) or (&quot;User&quot;)>
            <cftry>    
                 <cflogin ...> 
					:
            </cftry>
        </CFIF>
        <CFIF showLogin>
            <CFABORT>
        </CFIF>
    </cfif>
</cfif>
</cflogin>

If (isDefined(&quot;GetUsers&quot;) and auth), and (IsUserInRole(&quot;Admin&quot;) or (&quot;User&quot;)), you'll begin your call to
Code:
<CFLOGIN>
... but then you END it (
Code:
</CFLOGIN>
) even if those two cases aren't true. And, in fact, if they are true, then you're performing a
Code:
<CFABORT>
which prevents the closing tag from getting executed. And architecturally speaking, the closing call to a tag like
Code:
</CFLOGIN>
is where the actual processing of the tag occurs.



-Carl
 
I had try to the tip, remove my <cfabort> i still get that your not author.. not my login screen. any idea at all?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top