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