search /usr/local/bin/search.shThe indicated command would be invoked in response to a search request.
Slapd feeds a text representation of the request to the command on the command's standard input. Slapd then reads a text representation of the results or errors produced by the command from the command's standard output. These text results are converted to LDAP format and returned to the client. Slapd pays attention to the exit status of the command in some situations (i.e., to determine if a BIND request has succeeded or not).
The next sections discuss these input, output, and exit conventions in more detail.
BINDThe msgid parameter is a unique identifier for the operation. The method parameter will be one of the LDAP authentication methods listed in <ldap.h>. The only credential currently supported is a clear-text password (used with a simple bind).
msgid: <integer>[suffix: <dn>]+
dn: <binddn>
method: <integer>
credlen: <integer>
cred: <credentials>
UBBINDThis routine is provided so the backend can do any clean-up necessary.
msgid: <integer>
[suffix: <dn>]+
dn: <binddn>
SEARCHThe values of the scope parameter correspond to the various LDAP scopes listed in <ldap.h>.
msgid: <integer>
[suffix: <dn>]+
base: <baseobjectdn>
scope: 0 | 1 | 2
deref: 0 | 1 | 2 | 3
sizelimit: <integer>
timelimit: <integer>
filter: <ldapfilter>
attrsonly: 0 | 1
attrs: all | <attrlist>
The values of the deref parameter correspond to the various LDAP dereference options listed in <ldap.h>.
The filter parameter is a string representation of the LDAP search filter, as described in RFC 1588.
The <attrlist> is a space-separated list of attributes to retrieve.
COMPAREThe AVA (attribute value assertion) to compare to the entry is given in the <attrtype>: <attrvalue> line.
msgid: <integer>
[suffix: <dn>]+
dn: <entrydn>
<attrtype>: <attrvalue>
MODIFYThe add, delete and replace constructs indicate the modifications to make.
msgid: <integer>
[suffix: <dn>]+
dn: <entrydn>
[add: <attrtype>
[<attrtype>: <attrvalue]+]*
[delete: <attrtype>
[<attrtype>: <attrvalue]*]*
[replace: <attrtype>
[<attrtype>: <attrvalue]+]*
MODRDNThe deleteoldrdn parameter is a Boolean parameter (where 0 means false and 1 means true).
msgid: <integer>
[suffix: <dn>]+
dn: <entrydn>
newrdn: <rdn>
deleteoldrdn: 0 | 1
ADDThe <entry> parameter is a text representation of the entry to add in LDIF format, as described in Section 6.3.
msgid: <integer>
[suffix: <dn>]+
<entry>
ADD
msgid: <integer>
[suffix: <dn>]+
dn: <entrydn>
ABANDONFor the abandon operation, the msgid parameter gives the message ID of the operation to abandon.
msgid: <integer>
[suffix: <dn>]+
RESULTAll of the parameters are optional and will be given default values if omitted. If search entries have been returned, the RESULT follows the last one, with a blank line preceding the RESULT.
code: <integer>
matched: <partialdn>
info: <string>
This feature can be useful when trying to debug a problem with your SHELL backend. If you turn on SHELL debugging in slapd (level 1024), it will log anything it reads from a SHELL backend, allowing you to see your backend's debugging statements easily.
2. For bind operations, the exit status determines whether the bind was successful, and therefore whether the DN given should be trusted on future access control decisions.
An exit status of zero indicates the command was successful. A non-zero exit status indicates the command was not successful.
Note that on a bind operation, a zero exit status indicates that the DN given in the bind should be trusted on future access control decisions. This means that if, for example, a NOAUTH bind (no password provided) succeeds, you should be sure not to return an exit status of zero.
referral ldap://ldap.itd.umich.eduThis configuration defines a single SHELL backend, for entries in the "o=University of Michigan, c=US" subtree. Requests involving any other subtree will be sent to the LDAP server running on the host ldap.itd.umich.edu. A search operation will cause the command /usr/local/bin/searchexample.sh to be executed. Any other operation will result in an "unwilling to perform" error being returned to the client.
database shell
suffix "o=university of michigan, c=us"
search /usr/local/bin/searchexample.sh
Note that our simple example does no error checking, handles only very simple filters, ignores the scope, sizelimit, timelimit and other parameters, and is meant for illustrative purposes only. A real example should do more error checking and handle more situations.
1. #!/bin/shThe line numbers are for illustrative purposes only and do not appear in the actual file.
2. while [ 1 ]; do
3. read TAG VALUE
4. if [ $? -ne 0 ]; then
5. break
6. fi
7. case "$TAG" in
8. base:)
9. BASE=$VALUE
10. ;;
11. filter:)
12. FILTER=$VALUE
13. ;;
14. esac
15. done
16. LOGIN=`echo $FILTER | sed -e 's/.*=\(.*\))/\1/'`
17. PWLINE=`grep -i "^$LOGIN" /etc/passwd`
18. if [ $? = 0 ]; then
19. echo "DEBUG: passwd line is $PWLINE"
20. echo $PWLINE | awk -F: '{
21. printf("dn: cn=%s,%s\n", $1, base);
22. printf("cn: %s\n", $1);
23. printf("cn: %s\n", $5);
24. printf("sn: %s\n", $1);
25. printf("uid: %s\n", $1);
26. }' base="$BASE"
27. echo ""
28. fi
29. echo "RESULT"
30. echo "code: 0"
31. exit 0
Note the debugging statement on line 19. The output from this statement is ignored by slapd because of the DEBUG: prefix, unless debugging is turned on, in which case it may be logged (depending on the debugging level) but will otherwise not affect the search results sent.
Send comments about this page to: ldap-support@umich.edu