]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/unbind.c
221b0f83a392fb42d97df6093ee090b23665d838
[openldap] / servers / slapd / back-shell / unbind.c
1 /* unbind.c - shell backend unbind function */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 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     Operation           *op,
21     SlapReply           *rs
22 )
23 {
24         struct shellinfo        *si = (struct shellinfo *) op->o_bd->be_private;
25         FILE                    *rfp, *wfp;
26
27         if ( si->si_unbind == NULL ) {
28                 return 0;
29         }
30
31         if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
32             == (void *) -1 ) {
33                 return 0;
34         }
35
36         /* write out the request to the unbind process */
37         fprintf( wfp, "UNBIND\n" );
38         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
39         print_suffixes( wfp, op->o_bd );
40         fprintf( wfp, "dn: %s\n", (op->o_conn->c_dn.bv_len ? op->o_conn->c_dn.bv_val : "") );
41         fclose( wfp );
42
43         /* no response to unbind */
44         fclose( rfp );
45
46         return 0;
47 }