6 # Modify this to suit your needs. The "$1" is the map name, eg. "auto_master".
7 # To debug, simply run this script with map name as the only parameter. It's
8 # supposed to output map contents ("key location" pairs) to standard output.
9 SEARCHBASE="ou=$1,dc=example,dc=com"
11 VALUE_ATTRIBUTE="automountInformation"
13 /usr/local/bin/ldapsearch -LLL -x -o ldif-wrap=no -b "$SEARCHBASE" "$ENTRY_ATTRIBUTE" "$VALUE_ATTRIBUTE" | awk '
14 $1 == "'$ENTRY_ATTRIBUTE':" {
18 $1 == "'$VALUE_ATTRIBUTE':" && key {
19 printf "%s%s", key, OFS
21 for (i=2; i<NF; i++) {
22 printf "%s%s", $(i), OFS
24 printf "%s%s", $NF, ORS
27 # Double colon after attribute name means the value is in Base64.
28 $1 == "'$VALUE_ATTRIBUTE'::" && key {
29 printf "%s%s", key, OFS
31 for (i=2; i<NF; i++) {
32 printf "%s%s", $(i), OFS
34 printf "%s", $NF | "b64decode -rp"
35 close("b64decode -rp")