diff --git a/.cvsignore b/.cvsignore index e69de29..aad85da 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +mutt-1.2.5i.tar.gz diff --git a/mutt_ldap_query b/mutt_ldap_query new file mode 100644 index 0000000..ec980b8 --- /dev/null +++ b/mutt_ldap_query @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Last modified: 30 October 2000 +# + +FLAGS= + +# Create two temporary files. +umask 077 +TMPFILE=`mktemp /tmp/mutt.ldap.XXXXXX` +RESULTS=`mktemp /tmp/mutt.ldap.XXXXXX` + +if [ -n "$LDAPSERVER" ]; then + FLAGS="$FLAGS -h $LDAPSERVER" +fi +if [ -n "$LDAPBASEDN" ]; then + FLAGS="$FLAGS -b $LDAPBASEDN" +fi + +# Search. +ldapsearch $FLAGS '(&(objectclass=inetorgperson)(|(cn='"$1"'*)(givenname='"$1"'*)(surname='"$1"'*)(mail='"$1"'*)))' mail cn roomNumber 2> /dev/null >> $TMPFILE +ldapsearch -x $FLAGS '(&(objectclass=inetorgperson)(|(cn='"$1"'*)(givenname='"$1"'*)(surname='"$1"'*)(mail='"$1"'*)))' mail cn roomNumber 2> /dev/null >> $TMPFILE + +# Parse. +cat $TMPFILE | awk ' + /^mail:/ {MAIL=substr($0,6)} + /^cn:/ {NAME=substr($0,4)} + /^roomNumber:/ {ROOM=substr($0,12)} + /^$/ { MAIL=gensub("^ ","",g,MAIL) } + /^$/ { MAIL=gensub(" $","",g,MAIL) } + /^$/ { NAME=gensub("^ ","",g,NAME) } + /^$/ { NAME=gensub(" $","",g,NAME) } + /^$/ { ROOM=gensub("^ ","",g,ROOM) } + /^$/ { ROOM=gensub(" $","",g,ROOM) } + /^$/ { if(length(NAME) > 0) print MAIL "\t" NAME "\t" ROOM} + /^$/ { NAME = "" } +' > $RESULTS + +# Sort and present results. +sort -u $RESULTS > $TMPFILE +echo Querying ${LDAPSERVER}.... `cat $TMPFILE | wc -l` entries found. +cat $TMPFILE + +# Clean up. +rm -f $TMPFILE $RESULTS diff --git a/sources b/sources index e69de29..2495ae3 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +0ba5367059abdd55daceb82dce6be42f mutt-1.2.5i.tar.gz