Question
Problem using ListToArray and ReplaceList
I receive a single string value from a LDAP query which
contains all the members of a group.
This result is saved to a variable called "member"
--------------------------------------------------------------------------------------------
CN=Cattel\, Joseph A.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Morand\, Douglas,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Sonn\, Jr.\, David E.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Simons\, Steven F.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Reddy\, Bhavana,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Platt\, Betsy,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Normandin\, Patricia,OU=Patient Registration,DC=ha2000,DC=com, CN=Maillet\, Sue,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Campbell\, Margaret,OU=Applications,OU=Information Systems,DC=ha2000,DC=com
I want to create an array from this list so I can loop through it an make separate LDAP calls with each user so I add in a ";" character at the end of each line.
<cfset myArrayList = ListToArray(ReplaceList(member,"=com, ","=com;"),";")>
Then I loop through my newly created array.
<cfloop from="1" to=#ArrayLen(myArrayList)# step="1" index="i">
#myArrayList # <br />
</cfloop>
The problem I'm having is this is what I'm getting for the array values:
------------------------------------------------------------------------------------------------------------------------------
CN=Cattel\,JosephA.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Morand\,Douglas,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Sonn\,Jr.\,DavidE.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Simons\,StevenF.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Reddy\,Bhavana,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Platt\,Betsy,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Normandin\,Patricia,OU=PatientRegistration,DC=ha2000,DC=com
,CN=Maillet\,Sue,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Campbell\,Margaret,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
Why is there a "," character at the beginning of each of my array elements except the first one? Is it because of the ListToArray? I would have thought that my replacelist function would have removed the "," at the end of each element.
This result is saved to a variable called "member"
--------------------------------------------------------------------------------------------
CN=Cattel\, Joseph A.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Morand\, Douglas,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Sonn\, Jr.\, David E.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Simons\, Steven F.,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Reddy\, Bhavana,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Platt\, Betsy,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Normandin\, Patricia,OU=Patient Registration,DC=ha2000,DC=com, CN=Maillet\, Sue,OU=Applications,OU=Information Systems,DC=ha2000,DC=com, CN=Campbell\, Margaret,OU=Applications,OU=Information Systems,DC=ha2000,DC=com
I want to create an array from this list so I can loop through it an make separate LDAP calls with each user so I add in a ";" character at the end of each line.
<cfset myArrayList = ListToArray(ReplaceList(member,"=com, ","=com;"),";")>
Then I loop through my newly created array.
<cfloop from="1" to=#ArrayLen(myArrayList)# step="1" index="i">
#myArrayList # <br />
</cfloop>
The problem I'm having is this is what I'm getting for the array values:
------------------------------------------------------------------------------------------------------------------------------
CN=Cattel\,JosephA.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Morand\,Douglas,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Sonn\,Jr.\,DavidE.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Simons\,StevenF.,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Reddy\,Bhavana,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Platt\,Betsy,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Normandin\,Patricia,OU=PatientRegistration,DC=ha2000,DC=com
,CN=Maillet\,Sue,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
,CN=Campbell\,Margaret,OU=Applications,OU=InformationSystems,DC=ha2000,DC=com
Why is there a "," character at the beginning of each of my array elements except the first one? Is it because of the ListToArray? I would have thought that my replacelist function would have removed the "," at the end of each element.
