]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/unbind.c
93c6889468632f7381578ff7e6853c5d1920f1d2
[openldap] / servers / slapd / back-shell / unbind.c
1 /* unbind.c - shell backend unbind function */
2
3 #include "portable.h"
4
5 #include <stdio.h>
6
7 #include <ac/socket.h>
8 #include <ac/string.h>
9
10 #include "slap.h"
11 #include "shell.h"
12
13 void
14 shell_back_unbind(
15     Backend             *be,
16     Connection          *conn,
17     Operation           *op,
18     char                *dn,
19     int                 method,
20     struct berval       *cred
21 )
22 {
23         struct shellinfo        *si = (struct shellinfo *) be->be_private;
24         FILE                    *rfp, *wfp;
25
26         if ( si->si_unbind == NULL ) {
27                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
28                     "unbind not implemented" );
29                 return;
30         }
31
32         if ( (op->o_private = forkandexec( si->si_unbind, &rfp, &wfp ))
33             == -1 ) {
34                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
35                     "could not fork/exec" );
36                 return;
37         }
38
39         /* write out the request to the unbind process */
40         fprintf( wfp, "UNBIND\n" );
41         fprintf( wfp, "msgid: %d\n", op->o_msgid );
42         print_suffixes( wfp, be );
43         fprintf( wfp, "dn: %s\n", dn );
44         fclose( wfp );
45
46         /* no response to unbind */
47         fclose( rfp );
48 }