1

I have an ldap directory which contains some instances of a class called store, like this:

# ldapsearch -LLL -x -b "utente=las,dc=labammsis" -s base
dn: utente=las,dc=labammsis
objectClass: store
utente: las
indirizzo: 10.1.1.1
chiave: ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAA
 CFBAHTwDePWTXkV32Ggso3fxFHqJ9iPbiAiZ5TadkCIv1gF6GGVsHBUtfq+OuGwOCaDAdi/FXuxt2
 5Be4K0NGlmkwPvABaT3O6pXvA2ucUNzRm/dPME+kwMPc2lWT2MYOnjZ6TBiMl/PVXqHLREZjEJNDX
 4nW6C+7SgGA4d0FGIB+wKEy1gg== las@Client
modificato: 1

I want to extract only the attributes of type chiave, so the desired output is this:

ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAHTwDePWTXkV32Ggso3fxFHqJ9iPbiAiZ5TadkCIv1gF6GGVsHBUtfq+OuGwOCaDAdi/FXuxt25Be4K0NGlmkwPvABaT3O6pXvA2ucUNzRm/dPME+kwMPc2lWT2MYOnjZ6TBiMl/PVXqHLREZjEJNDX4nW6C+7SgGA4d0FGIB+wKEy1gg== las@Client

Searching the web I found this useful link, so I was able to do this:

# ldapsearch -LLL -x -b "utente=las,dc=labammsis" -s base chiave
dn: utente=las,dc=labammsis
chiave: ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAA
 CFBAHTwDePWTXkV32Ggso3fxFHqJ9iPbiAiZ5TadkCIv1gF6GGVsHBUtfq+OuGwOCaDAdi/FXuxt2
 5Be4K0NGlmkwPvABaT3O6pXvA2ucUNzRm/dPME+kwMPc2lWT2MYOnjZ6TBiMl/PVXqHLREZjEJNDX
 4nW6C+7SgGA4d0FGIB+wKEy1gg== las@Client

Not bad, but not exactly what I wanted.

Is there a way to achieve my goal only with some parameter of ldapsearch or should I manipulate the output to gain the desired output?

1 Answer 1

2

You can disable the wrapping with -o ldif-wrap=no, after that it's only filtering the output, for example with sed:

ldapsearch -LLL -x -b "utente=las,dc=labammsis" -s base -o ldif-wrap=no chiave \
| sed -ne 's/^chiave: //p'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .