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