From fe330241f0730a8269104119d43de69726216053 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 30 Nov 2017 03:53:09 +0000 Subject: [PATCH] etc/profile.d/ldap.sh --- etc/profile.d/ldap.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/etc/profile.d/ldap.sh b/etc/profile.d/ldap.sh index 1247475e..c75cec23 100644 --- a/etc/profile.d/ldap.sh +++ b/etc/profile.d/ldap.sh @@ -74,6 +74,22 @@ ldap_cn() { slapcat -a 'cn=*' $@ | grep ^dn | sed 's/dn: //' } +slapcat_csv() { + local aawk human=no human_opt='--noheader' + local aldap="$1"; shift + while [ $# -gt 0 ]; do + case "$1" in + -head) aawk+=" $1"; human_opt="" ;; + -human|-H) human=yes; human_opt=""; aawk+=" -head" ;; + -nohead) human_opt="--noheader"; aawk=${aawk// -head/} ;; + *) aawk+=" $1" ;; + esac + shift + done + [ $human = yes ] && slapcat_csv "$aldap" $aawk | csv2human $human_opt && return + slapcat -a "$aldap" -o ldif-wrap=no | awk -f $NB_ROOT/lib/awk/ldap2csv.awk -- $aawk +} + ldapsearch_csv() { local aldap aawk human=no human_opt='--noheader' while [ $# -gt 0 ]; do -- 2.47.3