DevOps Cloud (ADM)
Cybersecurity
IT Operations Cloud
The output from ldapsearch is sent to stdout as LDIF (LDAP Interchange Format). The format is reasonably readable, but not very flexible. In particular, lines longer than 78 characters are split, with the following line starting with a space. In many cases it is necessary to post-process the output to make it more readable. To obtain the output in single line one useful trick is that piping the LDIF through perl will undo the line splitting mentioned above (lines starting with a space are joined to the previous line). Use the following command of perl to undo the splitting.
Here is an example for the above
Default LDAP search:
ldapsearch -b "ou=ag-BDC8DE1582A8FE05, ou=AppliancesContainer, ou=Partition, ou=PartitionsContainer, ou=VCDN_ROOT, ou=accessManagerContainer, o=novell" -s sub -D cn=admin,o=novell" -x -w novell -s base romaAssociation –LLL
Output:
dn: ou=ag-BDC8DE1582A8FE05,ou=AppliancesContainer,ou=Partition,ou=PartitionsCo
ntainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell
romaAssociation: ou=3f3822a238615338,ou=ApplianceGroupContainer,ou=Partition,o
u=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell#1#romaA
pplianceGroup
Above we can see the output is seen in separated lines with each of 78 characters.
LDAP search piping to perl will get output in a single line for the attribute values.
ldapsearch -b "ou=ag-BDC8DE1582A8FE05, ou=AppliancesContainer, ou=Partition, ou=PartitionsContainer, ou=VCDN_ROOT, ou=accessManagerContainer, o=novell" -s sub -D "cn=admin,o=novell" -x -w novell -s base romaAssociation -LLL | perl -p00e 's/\r?\n //g'
dn: ou=ag-BDC8DE1582A8FE05,ou=AppliancesContainer,ou=Partition,ou=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell
romaAssociation: ou=3f3822a238615338,ou=ApplianceGroupContainer,ou=Partition,ou=PartitionsContainer,ou=VCDN_Root,ou=accessManagerContainer,o=novell#1#romaApplianceGroup
The output of above can be directly used as input to other applications because of single line output.