Hi Barry,

I managed to fix mine. I started from scratch and got it to work. I'm not
sure what was wrong, however do take a look at the thread the Patti reffered
to as it may solve your problem.

http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=7&threadid=
375144&highlight_key=y&keyword1=cflogin

Also, here is my revised code using NT authentication:

<cflogin idletimeout="1200" applicationtoken="public">
  <cfif isdefined("form.password") and isdefined("form.username")>
  <!--- WE NEED TO PROVIDE THIS SOMEHOW. NT TYPE LOGIN --->
  <CFSET Request.myDomain = "#form.domain#">
  <!--- TRY TO AUTHENTICATE USER --->
  <cfinvoke
  component = "NTSecurity"
  method = "authenticateUser"
  domain = "#Request.myDomain#"
  userid = "#form.username#"
  passwd = "#form.password#"
  returnVariable = "Auth">

  <!--- LOGIN USER --->
   <cfif #Auth# IS "True">
     <!--- AUTHENTICATION SUCCESS --->

            <!---GET USER INFO--->
    <cfquery name="emp" datasource="#request.dsn#" dbtype="ODBC">
    SELECT     employee_id as id, fname, lname, security_id,hr_employee_id
as hrid
    FROM       org_EMPLOYEE
    WHERE       (username = '#form.username#')
    </cfquery>

    <cfquery name="getroles" datasource="#request.dsn#" dbtype="ODBC">
    SELECT A.RoleID , B.Role As Roles
    FROM   ORG_ROLES A , ORG_ROLES_LOV B
    WHERE A.ID = B.ID AND A.EMPLOYEE_ID = 421
    </cfquery>

    <cfif emp.recordcount IS "1">
    <cfoutput query="emp">
    <cflock timeout="45" throwontimeout="Yes" name="Public">
    <CFSET Session.pr_hrempid = #hrid#>
    <CFSET Session.empid = #id#>
    <CFSET Session.fname = #fname#>
    <CFSET Session.lname = #lname#>
    <CFSET Session.seclevel = #security_id#>
    </CFLOCK>
    </cfoutput>

    <cfloginuser name="#form.username#" password="#form.password#"
roles="#RTrim('#getroles.roles#')#">

    <CFELSE>
    <!--- AUTHENTICATION SUCCEEDED BUT PROBLEM FINDING USERNAME IN
CONNECTIONS DB --->
    <cfset message = "Error 1: Your account is not active. Please contact
Connections.">
    <cflocation
url="../../#LOGINPATH#?url=#cgi.script_name#&#cgi.query_string#&message=#mes
sage#" addtoken="no">

    </cfif>

   <CFELSE>
   <!--- AUTHENTICATION FAILED --->
   <cfset message = "Error 2: There is a problem with your login.">
   <cflocation
url="../../#LOGINPATH#?url=#cgi.script_name#&#cgi.query_string#&message=#mes
sage#" addtoken="no">


   </CFIF>

 <cfelse>

 <!--- USER IS NOT AUTHENTICATED AND DID NOT COME FROM A LOGIN PAGE (FORM
LOGIN VARIABLES DON"T EXIST), SO SEND TO LOGIN PAGE
  This also occurs when user times out--->
 <cfset message = "">
 <cflocation
url="../../#LOGINPATH#?url=#cgi.script_name#&#cgi.query_string#&message=#mes
sage#" addtoken="no">
 </cfif>

</cflogin>


I am thinking of replacing CFLOCATION with CFINCLUDE like most are doing.

Hope this helps,

Frank

----- Original Message -----
From: "Barry Moore" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, July 24, 2002 6:42 PM
Subject: RE: CFLOGIN Problems


> Frank,
>
> You are not imagining things. I had some cflogin code that I had written
> during Beta test that worked just fine. I went to use it again last night
on
> a release version of CFMX and it does not work anymore. CF does not seem
to
> remember the login info from one page to the next. It logs the user in
just
> fine, but when they go to a new page all the login variables are gone.
>
> If you find an answer let me know, I will do the same.
>
> Barry
>
> -----Original Message-----
> From: Frank Mamone [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 24 July 2002 3:48 AM
> To: CF-Talk
> Subject: CFLOGIN Problems
>
>
> I am trying out the functionality of the CFLOGIN tsg snf it doesn't seem
to
> work as advertised.
>
> According to the docs "Code in thr cflogin tag only executes if there is
no
> user is logged in".
>
> The system authenticates and displays the protected page but when
accessing
> another page in the same dir the same code re-executes and doesn't see the
> form login vars and boots me to the login page.
>
> Am I missing something? Here is part of the code in Application.cfm:
>
> Thank you all.
>
> <cfset AllowedRoles = "Domain Users">
>
> <cflogin>
>  <cfif isdefined("form.password") and isdefined("form.username")>
>
>   <!--- WE NEED TO PROVIDE THIS SOMEHOW. SIMILAR TO NT LOGIN WOULD
DO. --->
>   <CFSET Request.myDomain = "STS1">
>   <!--- TRY TO AUTHENTICATE USER --->
>   <cfinvoke
>   component = "NTSecurity"
>   method = "authenticateUser"
>   domain = "#Request.myDomain#"
>   userid = "#form.username#"
>   passwd = "#form.password#"
>   returnVariable = "Auth">
>
>   <cfif #Auth# IS "True">
>   <!--- SUCCESS --->
>   <cfset failed = "no">
>   <!---NOW LET'S CHECK WHAT GROUPS(roles) I HAVE --->
>   <cfinvoke
>   component = "NTSecurity"
>   method = "getUserGroups"
>   domain = "#Request.myDomain#"
>   userid = "#form.username#"
>   passwd = "#form.password#"
>   returnVariable = "MyGroups">
>
>   <cfoutput>
>   <CFSET TheRoles ="#Replace('#MyGroups#',', ',',','All')#">
>   </cfoutput>
>
> <cfloginuser name="#form.username#"
>   password="#form.password#"
>   roles="#TheRoles#"
>      >
>   <CFELSE>
>
>  <!----Did not pass authentication so redirect with message--->
>
>   <cfset message = "There was a problem with your login.">
>   <cflocation
>
url="../../#LOGINPATH#?url=#cgi.script_name#&#cgi.query_string#&message=#mes
> sage#" addtoken="no">
>   </CFIF>
>
>
>
>  <CFELSE>
>  <!---No FORM login vars so redirect to login page --->
>  <cfset message = "">
>  <cflocation
>
url="../../#LOGINPATH#?url=#cgi.script_name#&#cgi.query_string#&message=#mes
> sage#" addtoken="no">
>
>
>  </CFIF>
> <cflogin>
>
>
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to