• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

LDAP output issue

New Here ,
Apr 22, 2013 Apr 22, 2013

Copy link to clipboard

Copied

I've been banging my head on the desk this morning looking at this code.  I don't know what I'm doing wrong. I can cfdump the data I want, but then I can't output it with cfoutput.  Here's the code:

<cfldap action="QUERY"

                       name="userSearch"

                       attributes="*"

                       start="ou=people,dc=myldapserver,dc=com"

                       scope="SUBTREE"

                       server="myldapserver.com"

                       port="xxxx"

                       filter="#filter#"

                       secure="CFSSL_BASIC">

                      

<cfdump var="#userSearch#" >

<cfoutput query="userSearch">#givenName#</cfoutput>

The cfdump returns the following: 

query
NAMEVALUE
1uid username
2objectClass comPerson
3givenName Jane
4sn Doe
5cn Jane Doe

The cfoutput gives this error message: Variable GIVENNAME is undefined.

Views

380

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 22, 2013 Apr 22, 2013

You have a query with 5 rows in it.  It has two columns, called respectively 'Name' and 'Value'.  So when you try to access #givenName# it fails because it doesn't know what you're on about.

Instead you'd have to refer to #userSearch.Name# (notice I've query-scoped the column, always a good idea). 

If you're specifically wanting to get just the value of the givenName, you could refer to it like this (if you know that it will always be the third column):

<cfoutput>#userSearch.Name[3]#</cfoutput>

NB:

...

Votes

Translate

Translate
Engaged ,
Apr 22, 2013 Apr 22, 2013

Copy link to clipboard

Copied

LATEST

You have a query with 5 rows in it.  It has two columns, called respectively 'Name' and 'Value'.  So when you try to access #givenName# it fails because it doesn't know what you're on about.

Instead you'd have to refer to #userSearch.Name# (notice I've query-scoped the column, always a good idea). 

If you're specifically wanting to get just the value of the givenName, you could refer to it like this (if you know that it will always be the third column):

<cfoutput>#userSearch.Name[3]#</cfoutput>

NB: this will just output 'givenName'.  So you'd maybe rather use #userSearch.Value[3]#

But it would be better to turn your query into a struct.  Alternatively, loop over the query.  Check the Name column on each iteration of the loop.  If Name = 'givenName', output the Value column.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation