View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfldap PreviousNext

cfldap

Provides an interface to a Lightweight Directory Access Protocol (LDAP) directory server, such as the Netscape Directory Server.

Forms tags, Internet Protocol tags

<cfldap 
server = "server_name"
port = "port_number"
username = "name"
password = "password"
action = "action"
name = "name"
timeout = "seconds"
maxRows = "number"
start = "distinguished_name"
scope = "scope"
attributes = "attribute, attribute"
filter = "filter"
sort = "attribute[, attribute]..."
sortControl = "nocase" and/or "desc" or "asc"
dn = "distinguished_name"
startRow = "row_number"
modifyType = "replace" or "add" or "delete"
rebind = "Yes" or "No"
referral = "number_of_allowed_hops"
secure = "multi_field_security_string"
separator = "separator_character"
delimiter = "delimiter_character">

cfftp, cfhttp, cfmail, cfmailparam, cfpop, Managing LDAP Directories in Developing ColdFusion MX Applications

ColdFusion MX:

Attribute

Req/Opt

Default

Description

server

Required

Host name or IP address of LDAP server.

port

Optional

389

Port

username

Required if secure = "CFSSL_BASIC"

(anonymous)

User ID

password

Required if secure = "CFSSL_BASIC"

 

Password that corresponds to user name.

If secure = "CFSSL_BASIC", V2 encrypts the password before transmission.

action

Optional

query

  • query: returns LDAP entry information only. Requires name, start, and attributes attributes.
  • add: adds LDAP entries to LDAP server. Requires attributes attribute.
  • modify: modifies LDAP entries, except distinguished name dn attribute, on LDAP server. Requires dn. See modifyType attribute.
  • modifyDN: modifies distinguished name attribute for LDAP entries on LDAP server. Requires dn.
  • delete: deletes LDAP entries on an LDAP server. Requires dn.

name

Required if action = "Query"

 

Name of LDAP query. The tag validates the value.

timeout

Optional

60

Maximum length of time, in seconds, to wait for LDAP processing.

maxRows

Optional

 

Maximum number of entries for LDAP queries.

start

Required if action = "Query"

 

Distinguished name of entry to be used to start a search.

scope

Optional

oneLevel

Scope of search, from entry specified in start attribute for action = "Query".

  • oneLevel: entries one level below entry.
  • base: only the entry.
  • subtree: entry and all levels below it.

attributes

Required if action = "Query", "Add", "ModifyDN", or "Modify"

 

For queries: comma-delimited list of attributes to return. For queries, to get all attributes, specify "*".

If action = "add" or "modify", you can specify a list of update columns. Separate attributes with a semicolon.

If action = "ModifyDN", ColdFusion passes attributes to the LDAP server without syntax checking.

filter

Optional

"objectclass = *"

Search criteria for action = "query".

List attributes in the form:
"(attribute operator value)" Example: "(sn = Smith)"

sort

Optional

 

Attribute(s) by which to sort query results. Use a comma delimiter.

sortControl

Optional

asc

  • nocase: case-insensitive sort
  • asc: ascending (a to z) case-sensitive sort
  • desc: descending (z to a) case-sensitive sort

You can enter a combination of sort types; for example, sortControl = "nocase, asc".

dn

Required if action = "Add", "Modify", "ModifyDN", or "delete"

 

Distinguished name, for update action. Example: "cn = Bob Jensen, o = Ace Industry, c = US"

startRow

Optional

Used with action = "query". First row of LDAP query to insert into a ColdFusion query.

modifyType

Optional

replace

How to process an attribute in a multi-value list.

  • add: appends it to any attributes
  • delete: deletes it from the set of attributes
  • replace: replaces it with specified attributes

You cannot add an attribute that is already present or that is empty.

rebind

Optional

No

  • Yes: attempt to rebind referral callback and reissue query by referred address using original credentials.
  • No: referred connections are anonymous

referral

Optional

 

Integer. Number of hops allowed in a referral. A value of 0 disables referred addresses for LDAP; no data is returned.

secure

Optional

 

Security to employ, and required information. One option:

  • CFSSL_BASIC

"CFSSL_BASIC" provides V2 SSL encryption
and server authentication.

separator

Optional

, [comma]

Delimiter to separate attribute values of multi-value attributes. Used by query, add, and modify actions, and by cfldap to output multi-value attributes.

For example, if $ (dollar sign), the attributes attribute could be "objectclass = top$person", where the first value of objectclass is top, and the second value is person. This avoids confusion if values include commas.

delimiter

Optional

; [semicolon]

Separator between attribute name-value pairs. Use this attribute if:

  • the attributes attribute specifies more than one item, or
  • an attribute contains the default delimiter (semicolon). For example: mgrpmsgrejecttext;lang-en

Used by query, add, and modify actions, and by cfldap to output multi-value attributes.

For example, if $ (dollar sign), you could specify
"cn = Double Tree Inn$street = 1111 Elm; Suite 100 where the semicolon is part of the street value.

If you use the query action, cfldap creates a query object, allowing access to information in the query variables, as follows:

Variable name

Description

queryname.recordCount

Number of records returned by query

queryname.currentRow

Current row of query that cfoutput is processing

queryname.columnList

Column names in query

If you use the security="CFSSL_BASIC" option, ColdFusion determines whether to trust the sever by comparing the server's certificate with the information in the jre/lib/security/cacerts keystore of the JRE used by ColdFusion MX. The ColdFusion MX default cacerts file contains information about many certificate granting authorities. If you must update the file with additional information, you can use the keytool utility in the ColdFusion jre/bin directory to import certificates that are in X.509 format. For example, enter the following:

keytool -import -keystore cacerts -alias ldap -file ldap.crt -keypass bl19mq

Then restart ColdFusion MX. The keytool utility initial keypass password is "change it". For more information on using the keytool utility, see the Sun JDK documentation

Characters that are illegal in ColdFusion can be used in LDAP attribute names. As a result, the cfldap tag could create columns in the query result set whose names contain illegal characters and are, therefore, inaccessible in CFML. In ColdFusion, illegal characters are automatically mapped to the underscore character; therefore, column names in the query result set might not exactly match the names of the LDAP attributes.

For usage examples, see Developing ColdFusion MX Applications.

<h3>cfldap Example</h3>
<p>Provides an interface to LDAP directory servers. The example uses the 
University of Connecticut public LDAP server. For more public LDAP servers,
see <a href="http://www.emailman.com">http://www.emailman.com</a>.</p>
<p>Enter a name and search the public LDAP resource. 
An asterisk before or after the name acts as a wildcard.</p>
<!--- If form.name exists, the form was submitted; run the query --->
<cfif IsDefined("form.name")>
   <!--- check to see that there is a name listed --->
   <cfif form.name is not "">
      <!--- make the LDAP query --->
      <cfldap 
          server = "ldap.uconn.edu"
          action = "query"
          name = "results"
          start = "dc=uconn,dc=edu"
          filter = "cn=#name#"
          attributes = "cn,o,title,mail,telephonenumber"
          sort = "cn ASC">
      <!--- Display results --->
      <center>
      <table border = 0 cellspacing = 2 cellpadding = 2>
         <tr>
            <th colspan = 5>
               <cfoutput>#results.recordCount# matches found
               </cfoutput></TH>
         </tr>
         <tr>
            <th><font size = "-2">Name</font></TH>
            <th><font size = "-2">Organization</font></TH>
            <th><font size = "-2">Title</font></TH>
            <th><font size = "-2">E-Mail</font></TH>
            <th><font size = "-2">Phone</font></TH>
         </tr>
         <cfoutput query = "results">
            <tr>
               <td><font size = "-2">#cn#</font></td>
               <td><font size = "-2">#o#</font></td>
               <td><font size = "-2">#title#</font></td>
               <td><font size = "-2">
                  <A href = "mailto:#mail#">#mail#</A></font></td>
               <td><font size = "-2">#telephonenumber#</font></td>
            </tr>
         </cfoutput>
         </table>
         </center>
      </cfif>
</cfif>

<form action="#cgi.script_name#" method="POST">
<p>Enter a name to search in the database.
<p>
<input type="Text" name="name">
<input type="Submit" value="Search" name="">
</form>

Contents > CFML Reference > ColdFusion Tags > cfldap PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


flappie said on Feb 16, 2004 at 3:53 AM :
the attribute action is not optional in MX 6.1. If ommited you get a nullpointer exception
clomvardias said on Apr 21, 2004 at 9:29 AM :
Why do I get this error when I try to use the "sort" attribute?

An error has occured while trying to execute sort :[LDAP: error code 12 - Unavailable Critical Extension].
GAlanShepherd said on Apr 22, 2004 at 8:30 AM :
The unavailable critical extension error appears because you have asked the server to sort the entries (cold fusion MX dropped client side sorting - why?) and marked it as a mandatory critical extension in the protocol. The server has responded saying that it does not support that extension (sorting presumably) and so the operation fails. It is possible that there is another critical extension it is not doing, but the sort is the most likely cause.
GAlanShepherd said on Apr 22, 2004 at 8:33 AM :
Why is the documentation for this tag so limited? Why is it not possible to obtain information on such things as size limit exceeded, partial result qualifiers etc?

And most irritatingly of all, cfldap appears to prepend ldap://server:389/ to the DNs of all entries returned that are a result of an alias dereferenced. If I try to use this in a subsequent operation as the DN, I get server unavailable. IT IS NOT USEFUL to do this! There should be an other flag indicating alias dereferenced.
GAlanShepherd said on Apr 22, 2004 at 9:57 AM :
why cant I specify the LDAP version? What if I want to use version 2?
halL said on Apr 22, 2004 at 10:17 AM :
We've entered a bug/enhancement report 55206 for GAlanShepherd's requests for changes to LDAP.
They are listed as:
1) Provide ColdFusion-side sorting of results (as was done in CF5)
2) Provide a flag indicating that an alias was dereferenced.
3) Provide a way to specify/use LDAP version 2.

Re documentation, we have a full chapter on using LDAP in the Developing ColdFusion MX Applications document, at http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/ldap.htm.
However, this may not provide all the information that you'd like to see.
If there are any specifics that aren't covered either here or in the Developing Applications chapter, please post additional Livedocs comments specifying what more you want covered.
GAlanShepherd said on Apr 22, 2004 at 2:26 PM :
It appears that a time limit exceeded error is no longer being picked up and thrown as an exception. I have the following:

<cftry>
<cfldap separator="|" name="#ldap_name#" action="#ldap_action#" scope="#ldap_scope#" start="#ldap_start#" filter="#ldap_filter#"
server="#ldap_server#" username="#ldap_user#" password="#ldap_pword#" maxrows="#ldap_maxrows#" attributes="#ldap_attributes#" referral="2"
rebind="yes" timeout="#ldap_timeout#">

<cfcatch type="any">
<CFDUMP var="#cfcatch#"><cfabort>
</cfcatch>
</cftry>

and according to the protocol log from the LDAP server, it is sending

messageID 3,
protocolOp {
result Code {
resultCode timeLimitExceeded,
matchedDN "",
errorMessage "",
}
}

This may be because the LDAP server is v2 and the error structure is subtly different than what cold fusion is expecting as it assumes version 3 servers.
GAlanShepherd said on Apr 23, 2004 at 6:19 AM :
Setting any value for timeout seems to cause the timeout value to be set to 1, rather than the value you set. If timeout is not specified, the value is set to 61, not 60.

I am using an LDAP v2 server and there is a v3 bind that fails before a successful v2 bind (why this inefficiency? I want to be able to specify v2!).
GAlanShepherd said on Apr 29, 2004 at 11:40 AM :
The documentation does not specify how to set LDAP service controls such as telling the server not to search aliases. Where can I find this information?
derrickrapley said on Jul 21, 2004 at 1:52 PM :
If you want to sort: The recordset from LDAP is returned as a query object. You can perform a query of queries on it.
jem_b said on Aug 12, 2004 at 11:25 AM :
I am unable to figure out how to retrieve all values of a multi-valued binary attribute, based on this documentation.
msoultan said on Aug 20, 2004 at 3:58 PM :
For some odd reason, when I submit the following query, coldfusion also asks for additional attributes. See below:

<cfldap action="query"
name="qCheckUsername"
server="#server#"
port="389"
attributes="uid"
maxrows="100"
start="cn=People,ou=school,dc=edu"
scope="subtree"
filter="(uid=23423423)"
username="uid=serviceaccount,cn=people,ou=school,dc=edu"
password="password">

When I look at the logs on the iPlanet LDAP server, the query is requesting a bunch of attributes in addition to uid: attrs="uid objectClass javaSerializedData javaClassName javaFactory javaCodebase javaReferenceAddress javaClassNames javaremotelocation"

I don't want coldfusion to ask for all these extra attributes. I only want it to ask "uid" and that's it. This will definately cause people problems if their admins are very tight on their LDAP security (like mine).

I also have not found any documentation regarding this behavior.
John Pickard said on Oct 8, 2004 at 9:33 AM :
Performing an LDAP query on a LDAP server to bring back all users belonging to a subtree is limited to 100 returned results e.g. 150 users may actually exist but ColdFusion will only return the first 100.
Josho said on Oct 15, 2004 at 10:38 AM :
Be careful that this max record limit isn't set on your server. If your server has a max record limit of 100, setting the max to 150 on your request won't change the server's setting.
D-Spair said on Oct 20, 2004 at 5:32 PM :
The <cfldap> doesn't seem to handle SSL gracefully. We have a self-signed certificate which doesn't seem to get accepted. Either that, or it doesn't handle TLS, which is the default encryption method for our server.
adrapley said on Nov 12, 2004 at 6:15 AM :
Is anyone aware that when you quey an ldap for multiple records in an OU, the first row in the result set is typically a row of empty values? At least this is my experience with Novell eDirectory.
einfo said on Nov 30, 2004 at 1:46 PM :
Are others having this same problem with cfldap not picking up time limit exceeded errors?
J.C. said on Dec 1, 2004 at 1:52 PM :
You know, I see more than enough info on how to query LDAP servers until the cows come home. Updating attributes is no problem. I'd really like to ADD a new user to AD or move a user from one container to another or maybe add a brand new group to AD. Anyone ever done that?? There's absolutely nothing about it out there. Try adding anything and it complains about required attributes. Go to Microsoft, and you can find required attributes. Go back to CFLDAP, add the required attributes...notta. Is this even possible??

Thanks!
Zeke_the_Web_Guru said on Oct 7, 2005 at 8:52 AM :
LDAP: error code 34 - Invalid DN Syntax

Solution found at http://groups.google.com/group/macromedia.coldfusion.security/browse_thread/thread/46aef1c75e4e781b/36aac02d2ae3ebe4%2336aac02d2ae3ebe4?sa=X&oi=groupsr&start=0&num=2

The invalid DN syntax is probably for the username parameter. You need to bind as a fully qualified DN. So change your username parameter to something like cn=username,ou=my group,dc=mycomany,dc=com.
Zeke_the_Web_Guru said on Oct 7, 2005 at 8:53 AM :
CFLDAP Sorting Problem

Solution found at http://www.dantor.com/support/cfdocs/Migrating_ColdFusion_5_Applications/cf_migration_guide6.html

You can no longer sort CFLDAP query results on the client side using the sort attribute. The sort attribute triggers a server-side sort. If the LDAP server does not support server-side sorting, CFLDAP throws an error.

The sort order depends on the LDAP server; for example, iPlanet Directory Server 5.0, Novell 6.0 server, Oracle Internet Directory 9i, Microsoft Active Directory, and others might each sort differently.

To do client-side sorting on the CFLDAP query results, use the ColdFusion Query of Queries feature.
joef163 said on Jul 6, 2006 at 7:55 AM :
The documentation provided at the top of the page has some error that I don't see corrected in any comments (although another technote on this issue has the correct information). Specifically, the default password is changeit (all one word). Secondly, you need to use the -storepass flag and not the -keypass flag.
Kingsler34 said on Jul 31, 2006 at 7:26 AM :
I was also having the same problems with cfldap not returning the "limit exceeded" errors. The ldap server had a limit set at 25 results...so if cfldap would return 26 or more, it would just return with no results instead of throwing the correct "administrative limit exceeded" error.

This seemed to only happen for me when I search for specific attributes. For example if your cfldap "attribute" value is set to anything but "*" it will NOT return the "administrative limit exceeded" error. Howeverm if you do the same search again, but this time with "attribute=*" then, you will recieve the correct error. Hope that helps!

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-p69.htm