Skip to main content
October 6, 2009
Question

Element RECORDCOUNT is undefined in USERLOOKUP

  • October 6, 2009
  • 1 reply
  • 3180 views

Hello!

I am trying to integrate LDAP authentication with a CF8 application.  My index.cfm file posts to my ldap.cfm file, and when the username and password are entered into the form I get the error: Element RECORDCOUNT in undefined in USERLOOKUP.

Here is my ldap.cfm file (I have sanitized the server and start so I don't post any senstive infomation):

cfparam name="user_id" default="#form.username#">
<cfparam name="username" default="#form.username#">
<cfparam name="passwd" default="#form.passwd#">
<cfparam name="error" default="NO ERRORS">
<cfparam name="firstName" default="">
<cfparam name="lastName" default="">
<cfparam name="defaultErrorMsg" default="There was a problem with your username/password.">
<!--- use generic message to complicate hacking --->

<!---  query ldap to see if the user exists --->


<cftry>
<cfldap name="userLookup"
      action="query"
  scope="subtree"
  server="ldap.edu"
  port="389"
  attributes="uid,dn,cn,sn"
         referral="0"
  filter="(&(uid=#username#))"
  start="cn=group,ou=Groups,dc=edu" />
<cfcatch type="any">
  <cfset error = defaultErrorMsg>
</cfcatch>
</cftry>

<!---  if a single row is returned, bind to authenticate --->


<cfif #userLookup.recordcount# EQ 1 >
<cftry>
  <cfldap name="userBind"
   action="query"
          scope="subtree"
   server="ldap.edu"
   port="389"
   username="#userLookup.dn#"
   password="#passwd#"
   attributes="dn"
   filter="(objectClass=*)"
   referral="0"
   start="#userLookup.dn#" />
      <cfcatch type="any">
   <cfset error = defaultErrorMsg>
      </cfcatch>
   </cftry>
<cfset firstName = LEFT( Mid( userLookup.cn, 1, FindOneOf( " ", userLookup.cn ) ), 20 )>
<cfset lastName = LEFT( userLookup.sn, 30 )>

<cfelse>
<cfset error = defaultErrorMsg>
</cfif>

Can anyone help me get past this error?  If more information is needed, please provide an email address that I can use to respond.  Thank you for your time.

This topic has been closed for replies.

1 reply

ilssac
Inspiring
October 6, 2009

Check what is being returned by your <cfldap...> call.

I suspect your ldap call is failing, and the logic is going through the <cfcatch...> block of your code.  But that block doesn't do anything but set a variable.

Then your code tries to execute a comparison on data that will  only exist if the <cfldap...> call is sucessful.

October 6, 2009

Thank you for your suggestion, Ian.  I placed <cfdump var="cfcatch#> between the <cfcatch></cfcatch> tags but didn't get any further information.  Is there another way to do it?

ilssac
Inspiring
October 6, 2009

No, if there was anything to catch that would be showing it.

Also put a <cfdump var="#userLookup#"> right after the <cfldap...> tag to see what it is returning if anything.

I would aslo put a <cfabort.> there just to stop any futher processing until I knew what is happening.