Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / servers / slapd / back-shell / searchexample.sh
blob8c80c28765465dd04fed092416bdd0ab2d6fceb4
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/servers/slapd/back-shell/searchexample.sh,v 1.9.2.3 2008/02/11 23:26:47 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 ## Portions Copyright (c) 1995 Regents of the University of Michigan.
17 ## All rights reserved.
19 ## Redistribution and use in source and binary forms are permitted
20 ## provided that this notice is preserved and that due credit is given
21 ## to the University of Michigan at Ann Arbor. The name of the University
22 ## may not be used to endorse or promote products derived from this
23 ## software without specific prior written permission. This software
24 ## is provided ``as is'' without express or implied warranty.
26 while [ 1 ]; do
27 read TAG VALUE
28 if [ $? -ne 0 ]; then
29 break
31 case "$TAG" in
32 base:)
33 BASE=$VALUE
35 filter:)
36 FILTER=$VALUE
38 # include other parameters here
39 esac
40 done
42 LOGIN=`echo $FILTER | sed -e 's/.*=\(.*\))/\1/'`
44 PWLINE=`grep -i "^$LOGIN" /etc/passwd`
46 #sleep 60
47 # if we found an entry that matches
48 if [ $? = 0 ]; then
49 echo $PWLINE | awk -F: '{
50 printf("dn: cn=%s,%s\n", $1, base);
51 printf("objectclass: top\n");
52 printf("objectclass: person\n");
53 printf("cn: %s\n", $1);
54 printf("cn: %s\n", $5);
55 printf("sn: %s\n", $1);
56 printf("uid: %s\n", $1);
57 }' base="$BASE"
58 echo ""
61 # result
62 echo "RESULT"
63 echo "code: 0"
65 exit 0