LDAP Object RDN Reverser
Novell Cool Solutions: Cool Tool
PERL code to manipulate LDAP extracted data and reverse an object's RDN allowing for the sorting of data by container/organizational unit.
|Posted:||2 Jan 2007|
Please read the note from our friends in legal before using this file.
RDNReverse.pl ReadMe File for v1.0 2007-01-01
Readme Text File Download: RDN Reverse.txt
It's easy enough for anybody to extract data from an LDAP directory, but trying to sort that data in a useful way is often hampered by not being able to sort by object context / container. This program reverses the order of an object's RDN giving you a field that can be used to sort a mass of data in to container (OU) order:-
cn=employee1.ou=finance.o=novell cn=employee2.ou=student.ou=finance.o=novell cn=employee3.ou=finance.o=novell cn=employee4.ou=IT.o=novell cn=employee5.ou=finance.o=novell cn=employee6.ou=student.ou=finance.o=novell
Can be sorted in to:
o=novell.ou=finance.cn=employee1 o=novell.ou=finance.cn=employee3 o=novell.ou=finance.cn=employee5 o=novell.ou=finance.ou=student.cn=employee2 o=novell.ou=finance.ou=student.cn=employee6 o=novell.ou=IT.cn=employee4
The input file must be a Comma Separated Values formatted file.
This program will only work where the input file contains one record per line.
If RDN components are separated by ',' then RDN MUST be enclosed in quotes in the input file.
Any Header line must be separated with ',' and have NO Quoted fields or special characters.
This program should work with output from any LDAP compliant database, including eDirectory, Active Directory etc; but it has only been tested with LDAP output from eDirectory.
The program has been tested on SUSE Linux 10 on x86 using Perl v5.8.8 and on MS Windows 2000 SP4 using ActivePerl v5.8.8. It should run on most Linux/Unix/Windows platforms with Perl v5.6 and above.
The program can deal with RDNs formatted with ',' or with '.' or a mixture of both BUT the outputted RDN and reverse RDN will all be formatted the same way, depending on how you answered the pre-run questions.
The program can deal with a mix of non-quotation enclosed and quotation enclosed data fields.
The program detects which operating system it is running on.
If the host OS is Linux you will be given the option to write the output using Linux or Windows line termination.
The program can accept a file with lines terminated by carriage- return+newline (ascii 13 & 10) or with just newline (ascii 10) or a mixture of both.
The program can also be used simply to change the formatting of an RDN from '.' to ',' or vice-versa.
This program DOES NOT work against LDIF files.
Any special characters in the RDN may invalidate the output.
The program does not work with multi-line fields (such as the LDAP exported Login Script attribute).
The resulting reverse RDN will always be enclosed in quotes.
- Name of input file [Default=ldapinput.csv]:
By default the program will look for a file called ldapinput.csv (lower-case on Linux/Unix).
- Name of output file [Default=ldapoutput.csv]:
By default the program will write to an output file called ldapoutput.csv (lower-case on Linux/Unix). The output file WILL BE OVER-WRITTEN if it already exists!
- What is the number of the RDN/OID field:
If you are not sure which field contains the RDN then open your CSV file in a spread-sheet program and count the columns (e.g. If the RDN is in column 'I' then it's field number is 9).
- Start lines to ignore (Headings etc.) [Default=0]:
Are there any non-data lines in the csv file? Such as a header line and data-empty lines?
- Fix Header Line 1 (Y/N)? [Default=N]:
If you answered 1 or more to the previous question then you will be prompted with this question. If you choose 'Y' to 'Fix' the header line, then the header line will be altered to include a heading for the 'Reverse RDN' field.
- (A)dd ReverseRDN or (R)eplace RDN [Default=A]:
If you choose 'A' a column containing the 'Reverse RDN' will be added to the output file. If you choose 'R' then in the output file the RDN field will be replaced with the 'Reverse RDN' field.
- Is The RDN Separator a ',' or a '.' [Default=',']:
You need to tell the program how the RDNs in the input csv file are formatted. Are they true LDAP format (using a ',') or eDirectory style (using a '.')?
- Output RDN separator ',' or '.' [Default=',']:
You have the option as to how the output RDN and Reverse RDN will be formatted.
- Terminate output lines with (W)indows Style or (L)inux style [Default=L]:
You will only be given this option if the program is running on a non-Windows machine. If you choose 'W' output lines will be terminated by carriage return+newline (ascii 13 & 10). If you choose 'L' then output lines will be terminated with newline (ascii 10) only.
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com