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':" {
19 for (i = 2; i <= NF; i++) {
26 # Double colon after attribute name means the value is in Base64.
27 $1 == "'$VALUE_ATTRIBUTE'::" {
28 for (i = 2; i <= NF; i++) {
35 # Empty line - end of record.
36 NF == 0 && key != "" && nvalues > 0 {
37 printf "%s%s", key, OFS
38 for (i = 2; i < nvalues; i++) {
39 printf "%s%s", value[i], OFS
42 printf "%s", value[nvalues] | "b64decode -rp"
43 close("b64decode -rp")
46 printf "%s%s", value[nvalues], ORS