#CATEGORYID# #CATEGORYNAME# #SURVEYID#
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => murpg [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> INSERT INTO AMUSER.HD_CATEGORY (CATEGORYID, CATEGORYNAME, SURVEYID) VALUES(#qSimpleQuery.CATEGORYID#, '#qSimpleQuery.CATEGORYNAME#', #qSimpleQuery.SURVEYID#) #CATEGORYID# #CATEGORYNAME# #SURVEYID#
[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => murpg [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) -->
INSERT INTO AMUSER.HD_CATEGORY (CATEGORYID, CATEGORYNAME, SURVEYID) VALUES(#categoryID#, '#categoryName#', #surveyID#) [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => mxstu [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 5 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> LOGIN PAGE
Invalid username or password Please try again.
Username:
Password: (case sensitive)
CFLDAP Component [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => murpg [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 6 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => murpg [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 7 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> CFLOOP - Coldfusion - Advanced Techniques

CFLOOP - Coldfusion - Advanced Techniques

All you need to do to test this code is to copy and past it. I need to insert all of the form variables into this query I created. Real simple but I am missing it. <cfif ISDefined("form.categoryid")> <!--- create a new query with 3 cols ---> <cfset qSimpleQuery = QueryNew("CATEGORYID, CATEGORYNAME, SURVEYID")> <!--- add a row to simple qSimpleQuery ---> <cfset newRow =QueryAddRow(qSimpleQuery)> <cfset fieldname1 = "#form.categoryid#"> <cfset fieldname2 = "#form.CATEGORYNAME#"> <cfset fieldname3 = "#form.SURVEYID#"> <!--- add values to the row just added ---> <cfloop from="1" to="2" index="i"> <cfset QuerySetCell(qSimpleQuery, "CATEGORYID", "#form.categoryid & i #")> </cfloop> <cfloop index = ...

  1. #1

    Default CFLOOP

    All you need to do to test this code is to copy and past it. I need to insert
    all of the form variables into this query I created. Real simple but I am
    missing it.

    <cfif ISDefined("form.categoryid")>
    <!--- create a new query with 3 cols --->
    <cfset qSimpleQuery = QueryNew("CATEGORYID, CATEGORYNAME, SURVEYID")>
    <!--- add a row to simple qSimpleQuery --->
    <cfset newRow =QueryAddRow(qSimpleQuery)>
    <cfset fieldname1 = "#form.categoryid#">
    <cfset fieldname2 = "#form.CATEGORYNAME#">
    <cfset fieldname3 = "#form.SURVEYID#">
    <!--- add values to the row just added --->
    <cfloop from="1" to="2" index="i">
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYID", "#form.categoryid & i #")>
    </cfloop>
    <cfloop index = "index_name2" list = "#fieldname2#" delimiters = ",">
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYNAME", "#index_name2#")>
    </cfloop>
    <cfloop index = "index_name3" list = "#fieldname3#" delimiters = ",">
    <cfset QuerySetCell(qSimpleQuery, "SURVEYID", "#index_name3#")>
    </cfloop>
    <!--- Display the values --->
    <cfoutput query="qSimpleQuery">
    #CATEGORYID# #CATEGORYNAME# #SURVEYID#<br>
    </cfoutput>

    <cfdump var="#qSimpleQuery#">
    </cfif>

    <form action="" method="post">
    <input name="CATEGORYID" type="hidden" value="6">
    <input name="CATEGORYID" type="hidden" value="8">
    <input name="CATEGORYNAME" type="hidden" value="Support in time">
    <input name="CATEGORYNAME" type="hidden" value="This is great">
    <input name="SURVEYID" type="hidden" value="4">
    <input name="SURVEYID" type="hidden" value="5">
    <input name="" type="submit">
    </form>

    murpg Guest

  2. #2

    Default Re: CFLOOP

    murpg wrote: 

    You'll have a single form field called categoryid (form.categoryid) with
    value "6,8" (but you shouldn't rely on that order), not two. The same hold
    for categoryname and surveyid.

    --
    <mack />


    Neculai Guest

  3. #3

    Default Re: CFLOOP

    murpg,

    It seems like most of the responders to your 3 posts are saying the same
    thing. Could explain which part is unclear?


    http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=2&thread
    id=1084309

    http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=7&thread
    id=1084244

    http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=7&thread
    id=1084569

    http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=7&thread
    id=1084496




    mxstu Guest

  4. #4

    Default Re: CFLOOP

    MXSTU,

    Thanks for getting back with me. Here is the solution that I came up with. I
    really like your solution it is a lot less labor intensive.
    <cfif ISDefined("form.categoryid")>
    <!--- create a new query with 3 cols --->
    <cfset qSimpleQuery = QueryNew("CATEGORYID, CATEGORYNAME, SURVEYID")>
    <cfset thisPos = 1>
    <cfloop index="i" list="#form.categoryId#" delimiters=",">
    <cfset newRow = QueryAddRow(qSimpleQuery)>
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYID", "#i#")>
    <cfset thisCatName = ListGetAt(form.CategoryName, thisPos , ",")>
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYNAME", "#thisCatName#")>
    <cfset thisSurID = ListGetAt(form.surveyid, thisPos , ",")>
    <cfset QuerySetCell(qSimpleQuery, "SURVEYID", "#thisSurID#")>
    <cfset thisPos = #thisPos# + 1>
    </cfloop>

    <cfloop query="qSimpleQuery">
    <cfquery datasource="#Application.DSN#">
    INSERT INTO AMUSER.HD_CATEGORY (CATEGORYID, CATEGORYNAME, SURVEYID)
    VALUES(#qSimpleQuery.CATEGORYID#, '#qSimpleQuery.CATEGORYNAME#',
    #qSimpleQuery.SURVEYID#)
    </cfquery>
    </cfloop>

    <!--- Display the values --->
    <cfoutput query="qSimpleQuery">
    #CATEGORYID# #CATEGORYNAME# #SURVEYID#<br>
    </cfoutput>

    <cfdump var="#qSimpleQuery#">
    </cfif>

    <form action="" method="post">
    <input name="CATEGORYID" type="hidden" value="17">
    <input name="CATEGORYID" type="hidden" value="18">
    <input name="CATEGORYNAME" type="hidden" value="Support in time">
    <input name="CATEGORYNAME" type="hidden" value="This is great">
    <input name="SURVEYID" type="hidden" value="4">
    <input name="SURVEYID" type="hidden" value="4">
    <input name="" type="submit">
    </form>

    murpg Guest

  5. #5

    Default Re: CFLOOP

    murpg,

    Glad you found a solution. I noticed you put the form values into a query.
    It doesn't hurt, but obviously isn't necessary to do the insert. If you are
    pulling the data for your form page, from a query, you might consider using
    dynamically named form fields instead. The dynamic method allows you to avoid
    the pitfalls of lists and empty form fields and the code is more clear (IMO)

    Btw, you don't need all the extra pound signs in these types of cfset
    statements:

    Write ....

    <cfset QuerySetCell(qSimpleQuery, "CATEGORYID", i)>
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYNAME", thisCatName)>
    <cfset QuerySetCell(qSimpleQuery, "SURVEYID", thisSurID)>
    <cfset thisPos = thisPos + 1>

    ... instead of ...

    <cfset QuerySetCell(qSimpleQuery, "CATEGORYID", "#i#")>
    <cfset QuerySetCell(qSimpleQuery, "CATEGORYNAME", "#thisCatName#")>
    <cfset QuerySetCell(qSimpleQuery, "SURVEYID", "#thisSurID#")>
    <cfset thisPos = #thisPos# + 1>




    <!--- form page --->
    <form action="yourActionPage.cfm" method="post">
    <cfoutput query="yourDataQuery">
    <input name="CATEGORYID#currentRow#" type="hidden" value="#CATEGORYID#">
    <input name="CATEGORYNAME#currentRow#" type="hidden"
    value="#CATEGORYNAME#">
    <input name="SURVEYID#currentRow#" type="hidden" value="#SURVEYID#">
    </cfoutput>
    <cfoutput>
    <input type="hidden" name="numberOfRows"
    value="#yourDataQuery.recordCount#">
    </cfoutput>
    <input name="" type="submit">
    </form>


    <!--- action page --->
    <cfloop from="1" to="#form.numberOfRows#" index="row">
    <cfset surveyID = val(form["surveyID"& row])>
    <cfset categoryID = val(form["categoryID"& row])>
    <cfset categoryName = form["categoryName"& row]>
    <!--- query not tested --->
    <cfquery datasource="#Application.DSN#">
    INSERT INTO AMUSER.HD_CATEGORY (CATEGORYID, CATEGORYNAME, SURVEYID)
    VALUES(#categoryID#, '#categoryName#', #surveyID#)
    </cfquery>
    </cfloop>

    mxstu Guest

  6. #6

    Default Re: CFLOOP

    I was wondering if I could get you to take a look at this code. I have created
    a login function where I am combining CFLDAP & the new MX cflogin tag. I am
    building the LDAP tag in a component with the eventual goal to call it as a web
    service not just yet though. The code works great except password is not
    getting passed properly to CFLAP. Here is what happens. I am able to login
    using just the username. If I leave the password field blank or just type
    anything into the password field I am able to login. If I don't put in the
    proper username or a wrong username I am not able to login.
    Here is the order that I will paste the code. Please note I have taken out
    the CFLDAP attributes for privacy.

    1. Application.cfm
    2. Login_form.cfm
    3. SurveyAdmin.cfm



    APPLICATION FILE

    <cfapplication sessionmanagement="yes" name="SurveyApplication"
    clientmanagement="yes" sessiontimeout="#CreateTimeSpan(0, 0, 30, 0)#">

    <!--- set the necessary application and session variables --->
    <cfparam name="Application.DSN" default="AMSURVEY">
    <cfif Isdefined("url.logout")>
    <cflock scope= "APPLICATION" type= "EXCLUSIVE" timeout= "10">
    <cfset Session.Admin_UserAuth= false>
    <cfset Session.UserGroupName= "">
    <cfset Session.UserName= "">
    <cfset UserSearchFailed = 1>
    <cfset Session.Roles= "">
    </cflock>
    <cflogout>
    <cflocation url="index.cfm">
    </cfif>
    <cflogin>
    <cfif not isdefined("form.login")>
    <cfinclude template="login_form.cfm">
    <cfabort>
    <cfelse>
    <!--- would validate username and password here --->
    <cfinvoke
    component="gmprojects.survey.admin.SurveyAdmin"
    method="SearchSurveyPerson"
    returnvariable="SearchSurveyPersonRet">
    <cfinvokeargument name="username" value="#Form.username#">
    <cfinvokeargument name="Password" value="#Form.Password#">
    <cfinvokeargument name="getGroup" value="#Form.getGroup#">
    </cfinvoke>

    <!--- This Holds the First Name and Last Name for personalization --->
    <cflock scope="application" type="exclusive" timeout="20">
    <cfset Session.Username = "#SearchSurveyPersonRet.CN#">
    <cfif Session.Username EQ "James Wilson">
    <cfset Session.Roles = "Super Admin">
    <cfelse>
    <cfset Session.Roles = "Admin">
    </cfif>
    </cflock>
    <cfif SearchSurveyPersonRet.recordcount is 0>
    <cfinclude template="login_form.cfm">
    <cfabort>
    </cfif>

    <cfloginuser name="#Session.Username#" password="#form.password#"
    roles="#Session.Roles#">

    </cfif>
    </cflogin>

    LOGIN PAGE
    <cfparam name="Form.username" default="">
    <cfparam name="Form.Password" default="">
    <cfparam name="Form.getGroup" default="">
    <cfif ISDefined("Form.Login")>
    <cfinvoke method="SearchSurveyPerson"
    component="gmprojects.survey.admin.SurveyAdmin"
    returnvariable="SearchSurveyPersonRet">
    <cfinvokeargument name="username" value="#Form.username#">
    <cfinvokeargument name="Password" value="#Form.Password#">
    <cfinvokeargument name="getGroup" value="#Form.getGroup#">
    </cfinvoke>
    </cfif>
    <form method=post action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>">
    <table border=1 cellpadding=5 cellspacing=0 align="center"
    class="contentText"><tr><td>
    <cfif IsDefined("SearchSurveyPersonRet.recordcount") AND
    SearchSurveyPersonRet.recordcount is 0>
    <tr>
    <td colspan="2">Invalid username or password Please try again.</td>
    </tr>
    </cfif>
    <tr><td>Username:</td>
    <td><input type=text name="username" size=15 maxlength=50></td></tr>
    <tr>
    <td nowrap>Password: <span style="color:#FF0000; font-style:
    italic;">(case sensitive)</span></td>
    <td><input type=password name="password" size=15 maxlength=50><input
    name="getGroup" type="hidden" value="cn="></td></tr>
    <tr>
    <td colspan="2" align="center"><input type=submit name="Login"
    value="Login"></td>
    </tr>
    </table>
    </form>

    CFLDAP Component

    <cfcomponent displayName="SurveyAdmin" hint="This controls all of the queries
    needed in the survey admin">
    <cffunction name="SearchSurveyPerson" access="public" output="0"
    returntype="query">
    <CFTRY>
    <CFLDAP ACTION = "QUERY"
    NAME = "userSearch"
    ATTRIBUTES = "#attributes#"
    START = "#root#"
    SCOPE = "SUBTREE"
    SERVER = "#LDAP_SERVER#"
    PORT = "#LDAP_PORT#"
    FILTER = "#filter#"
    USERNAME = "#LDAP_username#"
    PASSWORD = "#LDAP_password#">

    <CFCATCH TYPE = "ANY">
    <CFSET UserSearchFailed = 1>
    </CFCATCH>
    </CFTRY>

    <!------------ If error or no match for username ----------------->
    <CFIF (NOT userSearch.recordcount)>
    <CFSET UserSearchFailed = 1>
    </CFIF>

    <!--- pass the user's DN and password to see if the user authenticates --->
    <CFTRY>
    <CFLDAP ACTION = "QUERY"
    NAME = "auth"
    ATTRIBUTES = "#attributes#"
    START = "#root#"
    SCOPE = "SUBTREE"
    FILTER = "#filter#"
    SERVER = "#LDAP_SERVER#"
    PORT = "#LDAP_PORT#"
    USERNAME = "#userSearch.dn#"
    PASSWORD = "#Form.Password#">

    <CFCATCH TYPE = "ANY">
    <CFSET UserSearchFailed = 1>
    </CFCATCH>

    </CFTRY>
    <!--- If ldap query returned the user is not valid --->
    <CFIF (NOT IsDefined("auth")) OR auth.RecordCount LTE 0>
    <CFSET UserSearchFailed = 1>
    </CFIF>

    <CFLDAP ACTION = "QUERY"
    NAME = "groupSearch"
    ATTRIBUTES = "cn,member"
    START = "#root#"
    SCOPE = "SUBTREE"
    SERVER = "#LDAP_SERVER#"
    PORT="#Variables.LDAP_PORT#"
    FILTER="(&(objectclass=*)(cn=))"
    USERNAME = "#LDAP_username#"
    PASSWORD = "#LDAP_password#">

    <cfif NOT FindNoCase(userSearch.cn, groupSearch.member)>
    <CFSET UserSearchFailed = 1>
    </cfif>
    <cfreturn userSearch>
    </cffunction>
    </cfcomponent>

    murpg Guest

  7. #7

    Default Re: CFLOOP

    Dear MXSTU,

    Thanks for helping out. I found a solution to the LDAP problem sort of. I
    went through the component using <cfdump> & <cfabort> until I realized that the
    value on UserSearchFailed was indeed equal to 1 after the code below. So, just
    before the <cfreturn> tag in the function I added an if statement that said if
    UserSearchFailed EQ 1 then then to use use cflocation to return them to the
    login form. My problem with this was that when they returned I was not able to
    pass them trhough with the right username and password without closing the
    browser. I did find a temporary solution that works. Rather than sending them
    to the login page I am sending them to another page which has a cflocation to
    the index page. Any thoughts on how I might avoid this step of sending them to
    another page before the cflogin page?

    <!--- pass the user's DN and password to see if the user authenticates --->
    <CFTRY>
    <CFLDAP ACTION = "QUERY"
    NAME = "auth"
    ATTRIBUTES = "#attributes#"
    START = "#root#"
    SCOPE = "SUBTREE"
    FILTER = "#filter#"
    SERVER = "#LDAP_SERVER#"
    PORT = "#LDAP_PORT#"
    USERNAME = "#userSearch.dn#"
    PASSWORD = "#Form.Password#">

    <CFCATCH TYPE = "ANY">
    <CFSET UserSearchFailed = 1>
    </CFCATCH>

    </CFTRY>
    <!--- If ldap query returned the user is not valid --->
    <CFIF (NOT IsDefined("auth")) OR auth.RecordCount LTE 0>
    <CFSET UserSearchFailed = 1>
    </CFIF>


    murpg Guest

Similar Threads

  1. Question Need help with MOD and cfloop
    By TheBorg in forum ColdFusion
    Replies: 0
    Last Post: May 30th, 07:18 AM
  2. CFLOOP
    By cfuser7 in forum Coldfusion Database Access
    Replies: 9
    Last Post: September 14th, 08:43 PM
  3. cfloop
    By drmaves in forum Coldfusion - Getting Started
    Replies: 10
    Last Post: September 13th, 04:36 PM
  4. cfloop bug
    By Simon_Edwards_sgf in forum Macromedia ColdFusion
    Replies: 15
    Last Post: August 29th, 11:14 PM
  5. Cfloop..
    By Seth Buntin in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: June 29th, 05:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •