'ldapsearch - truncating the result
I am using ldapsearch for getting radius secret, but it is giving truncated result
Command I am using is :
./ldapsearch -p 1545 -Z -X -D "cn=Directory Manager" -w passwd -b "o=platform" "(objectClass=*)" | grep -i secret
result produced is :
ss-secret=ahksdf6fakh7fajkfhaffjkfjfhafajkfh234578fajf171jkh25/525jhsfasjh8jjk7
where as actual value in LDAP is
ss-secret=ahksdf6fakh7fajkfhaffjkfjfhafajkfh234578fajf171jkh25/525jhsfasjh8jjk7afjfh8/gSqtulkjfa8lfjakl3
I am using OpenDJ LDAP.
Solution 1:[1]
Use -T argument like
./ldapsearch -p 1545 -T -Z -X -D "cn=Directory Manager" -w passwd -b "o=platform" "(objectClass=*)" | grep -i secret
This will give you complete output.
Solution 2:[2]
Try "ldapsearch -o ldif-wrap=no ...".
Search the man page for "wrap".
I am using OpenLDAP in the ldap-utils package on debian.
Solution 3:[3]
for Debian based system you have to add "-o ldif-wrap=no "
example: ldapsearch -xLLL -o ldif-wrap=no -H ldap://hostname:port/
from the man page of ldapsearch ubuntu 16.04:
-T path
Write temporary files to directory specified by path (default: /var/tmp/)
so it has no relation with formatting the output
Solution 4:[4]
Unfortunately, none of those options worked for me. I went to trusty sed and awk and solved the problem.
ldapsearch options > outfile
## sed to remove the space at the beginning of wrapped lines.
sed -i 's/^ //g' outfile
## Awk to join the lines if 78
awk '{if(length($0) == 78) {printf $0} else {print $0} }' outfile > outfile.nowrap
Solution 5:[5]
Going to try the wrap thing but this has been my go-to for years:
ldapsearch -xLLL cn=WHATEVER | perl -p00e 's/\n /g'
It’s ugly, which is why I landed here looking for a better way, but it works without fail.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | codingenious |
| Solution 2 | Curtis Yallop |
| Solution 3 | Armali |
| Solution 4 | Doj |
| Solution 5 | Jeremy Caney |
