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

CF9 - convert LDAP data into associative array?

LEGEND ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

Hello, everyone.

Does anyone have any suggestions on a good way to convert LDAP data into an associative array with the key being the fieldname?

For example:

dn: CN=First Last, OU=Dept A, OU=Dept B, OU=Domain Users,DC=hq,DC=domainname,DC=com

changetype: edit

sn: Last

description: Dept C

telephoneNumber: xxx-xxx-xxxx

givenName: First

empID: ab1234x

mail: Last.First@domainname.com

There are several thousand similar to the above; some will have three lines of data, some as many as twelve, each individual separated by double line breaks (<br />).  I need to make an array where "dn", "changetype", "sn", etc., are the keys with the text after the colon as the value.

What is the best way to do this?

Thank you,

^_^

Views

746

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
Advocate ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

What is the source of the data?  Is it a text file with the above data?  Is it an LDAP query?  Spreadsheet?

Jason

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
LEGEND ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

Hi, Jason.

Sorry.. I still haven't completely woken up, yet. 

The data is in a .ldf file that resides on the server.  Right now, I'm using CFFILE to read it into a string.  I can also set it up for JavaScript, if that would be easier/quicker/more efficient.

^_^

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
LEGEND ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

Well.. I pushed ahead, a little, and am trying to manually create an array of arrays.  But the nested array is (at least, what I _plan_ for it to be) an associative array.  So I'm splitting on the colon ":" and trying to set the left value as the key and the right value as the value.

But I'm getting an error message: The value Dn cannot be converted to a number.

I've tried many things, including ToString, and I just can't seem to nail it.

^_^

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
LEGEND ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

Inside CFSCRIPT:

for(i=1; i lte arrayLen(ldap_data2); i++){

  thisArray = listToArray(ldap_data2,"""",false); thatArray = ArrayNew(1);

  for(j=1; j lte arrayLen(thisArray); j++){

    thatArray[ListGetAt(thisArray,1,':')] = thatArray[ListGetAt(thisArray,2,':')];

  }

}

^_^

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
LEGEND ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

LATEST

I got it partially figured out.  I wasn't using the index of the array as notation.  thatArray[ListGetAt(thisArray,1,':')] =  is what kind of fixed it.

However, instead of having an index array of associative arrays, I have an index array of index arrays, each of which contains a single struct that just happens to be an associative struct.

Sigh.. the search continues.. suggestions greatly appreciated.

Thank you,

^_^

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