I have written a ColdFusion component to interact through LDAP with Active Directory. The component is working great and I am getting the functionality I need from it.
However, I am building an additional method by which I plan to enumerate all of the OU objects in AD. While I recursively move through each OU object and its sub objects building a hierarchy my code is presently only returning a string. This string provides decent display information but is not interactive. My eventual goal is a completely interactive folder tree. I think an array of structures is probably where I need to go, but I am having a hard time thinking my way there as I am unfamiliar with structures.
I've attached my code and an example of the returned string. Let me know if I need to provide you with more information. Any help would be greatly appreciated.
my code
my output
However, I am building an additional method by which I plan to enumerate all of the OU objects in AD. While I recursively move through each OU object and its sub objects building a hierarchy my code is presently only returning a string. This string provides decent display information but is not interactive. My eventual goal is a completely interactive folder tree. I think an array of structures is probably where I need to go, but I am having a hard time thinking my way there as I am unfamiliar with structures.
I've attached my code and an example of the returned string. Let me know if I need to provide you with more information. Any help would be greatly appreciated.
my code
Code:
<cffunction name="enumerateOU" returntype="string"
displayname="Enumerate OU Objects"
hint="recursively displays all container and organizationalUnit objects under a specified base">
<cfargument name="base_ou" type="string" required="yes">
<cfargument name="string_space" type="string" required="yes">
<cfargument name="base_branch" type="string" required="yes">
<cfset var results = "">
<cfset var retVal = "">
<cfset var currentRow = 0>
<cfset sub_ou_results=application.ldapCFC.getObject('oneLevel',
'name,canonicalName,objectCategory',
'#base_ou#,DC=my,DC=organization,DC=org',
'(OU=*)',
'name',
'asc')>
<cfloop query="sub_ou_results">
<cfset currentRow = currentRow + 1>
<cfset results = enumerateOU('OU=' & name & ',' & base_ou, string_space & ' ', base_branch & '.' & currentRow)>
<cfset retVal = retVal & '<br>' & string_space & base_branch & '.' & currentRow & ' ' & name & results>
</cfloop>
<cfreturn retVal>
</cffunction>
<cfset base_ou_results ="">
<cfset base_ou_results=application.ldapCFC.getObject('onelevel',
'name,canonicalName',
'DC=my,DC=organization,DC=org',
'(OU=*)',
'name',
'asc')>
<cfsetting requestTimeOut="500">
<cfset testEm = "">
<cfoutput query="base_ou_results">
<br>#base_ou_results.CurrentRow# #name#
<cfset testEm = enumerateOU('OU=' & name, ' ', base_ou_results.CurrentRow)>
#testEm#
</cfoutput>
my output
Code:
1 Cip
1.1 Cad
1.2 Portable
1.3 REX
1.3.1 ChkOut
1.3.2 Prod
1.4 Sppa
1.5 Test
1.5.1 Testhierarchy
1.6 WC
1.7 XR
generated by testEm variable containing:
<br> 1.1 Cad<br> 1.2 Portable<br> 1.3 REX<br> 1.3.1 ChkOut<br> 1.3.2 Prod<br> 1.4 Sppa<br> 1.5 Test<br> 1.5.1 Testhierarchy<br> 1.6 WC<br> 1.7 XR