I recently had a project where <CFLDAP> couldn't handle the number of Ldap requests I needed to perform. I looked to alternatives, and had trouble finding anything. Until I stumbled onto the entries on Dave Ross's site regarding JLDAP:
The code there wasn't exactly what I needed; however since it was much more specific than I required, it was easy to reverse engineer. So I wrote a CFC that replaces most of the functionality of CFLDAP with a CFC that uses JLDAP.
Pros
Cons
If have to do a single operation or just a few operations, use CFLDAP. It's just easier.
If you have to do thousands of LDAP operations in one request, javaldap.cfc might be for you.
Calling this code will find all of the users named "Jon" on your ldap server and rename then "John."
1: <cfset ldapserver = "<ldapserver>" />
2: <cfset ldapdn = "<distinguished name of account that has access.>" />
3: <cfset ldappassword = "<password of account that has access.>" />
4:
5: <!--- Create the object --->
6: <cfobject type="component" name="ldapObj" component="javaldap">
7:
8: <!--- Initialize the LDAP object --->
9: <cfinvoke component="#ldapObj#" method="init">
10: <cfinvokeargument name="server" value="#ldapserver#"/>
11: <cfinvokeargument name="dn" value="#ldapdn#"/>
12: <cfinvokeargument name="password" value="#ldappassword#"/>
13: </cfinvoke>
14:
15: <!--- Search for all users with a first name of 'Jon' --->
16: <cfinvoke component="#ldapObj#" method="search" returnvariable="searchRet">
17: <cfinvokeargument name="filter" value="givenName=jon"/>
18: <cfinvokeargument name="attributes" value="dn"/>
19: </cfinvoke>
20:
21: <!--- Loop through the return results --->
22: <cfloop query="searchRet">
23:
24: <cfset userdn = dn />
25: <cfset userdetails['givenName'] = "John" />
26:
27: <!--- Change their first name to 'John' --->
28: <cfinvoke component="#ldapObj#" method="update">
29: <cfinvokeargument name="userdn" value="#userdn#"/>
30: <cfinvokeargument name="userdetails" value="#userdetails#"/>
31: </cfinvoke>
32:
33: </cfloop>
Before you can use this, you must install JLDAP. To do that:
Thanks to Dave Ross who laid the ground work for all of this.