Skip to main content
nikos101
Inspiring
July 16, 2009
Answered

How do I find the number of users returned by a cfldap query?

  • July 16, 2009
  • 1 reply
  • 762 views

How do I find the number of users returned by a cfldap query?

I'm not allowed to do something like:

<cfif ArrayLen(results.rows) gt 1>

I then get an error:

faultCode:Server.Processing faultString:'Unable to invoke CFC - Object of type class coldfusion.tagext.net.LdapResultTable cannot be used as an array' faultDetail:''

Many thanks for any light you can shed

    This topic has been closed for replies.
    Correct answer ilssac

    To expand on Dan's answer.

    #results.USNCreated# is a reference to the entire column.  Inside of an <cfoutput query=""> OR a <cfloop query=""> loop this short cut is allowed.  But if you want to access the record set directly outside of one of these loop structures, you need to use the fully qualified query.column[row] or query["column"][row] syntax.

    I.E

    <cfqueryparam value="#results.USNCreated[1]#" cfsqltype="cf_sql_varchar">

    1 reply

    ilssac
    Inspiring
    July 16, 2009

    The <cfldap...> tag returns a query result set not an array.  Or rather it is a very specialized array.

    Anyway you use normal query features just like one you got from a relational database sql statement.

    I.E.

    <cfoutput>#result.recordCount#</cfoutput>

    Or for your example.

    <cfif result.recordCount GT 1>

    nikos101
    nikos101Author
    Inspiring
    July 16, 2009

       Cheers again Ian for your many helps,

    it now won't let me do

    <cfqueryparam value="#results.USNCreated#" cfsqltype="cf_sql_varchar">

    I get the message:

    faultCode:Server.Processing faultString:'Unable to invoke CFC - Error Executing Database Query.' faultDetail:'[Macromedia][SQLServer JDBC Driver][SQLServer]The name "results.USNCreated" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.'

    Inspiring
    July 16, 2009

    Depending on what you are attempting, either

    specify a row number

    or

    use a valuelist and set the list attibute to yes.