]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/searchexample.sh
Add comments
[openldap] / servers / slapd / back-shell / searchexample.sh
1 #! /bin/sh
2 # $OpenLDAP$
3 ## Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5
6 while [ 1 ]; do
7         read TAG VALUE
8         if [ $? -ne 0 ]; then
9                 break
10         fi
11         case "$TAG" in
12                 base:)
13                 BASE=$VALUE
14                 ;;
15                 filter:)
16                 FILTER=$VALUE
17                 ;;
18                 # include other parameters here
19         esac
20 done
21
22 LOGIN=`echo $FILTER | sed -e 's/.*=\(.*\))/\1/'`
23
24 PWLINE=`grep -i "^$LOGIN" /etc/passwd`
25
26 sleep 60
27 # if we found an entry that matches
28 if [ $? = 0 ]; then
29         echo $PWLINE | awk -F: '{
30                 printf("dn: cn=%s,%s\n", $1, base);
31                 printf("objectclass: top\n");
32                 printf("objectclass: person\n");
33                 printf("cn: %s\n", $1);
34                 printf("cn: %s\n", $5);
35                 printf("sn: %s\n", $1);
36                 printf("uid: %s\n", $1);
37         }' base="$BASE"
38         echo ""
39 fi
40
41 # result
42 echo "RESULT"
43 echo "code: 0"
44
45 exit 0