]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/unbind.c
099536ae5e31dc4025b3a196adb3092cbe7d8ab8
[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                 return 0;
30         }
31
32         if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
33             == (void *) -1 ) {
34                 return 0;
35         }
36
37         /* write out the request to the unbind process */
38         fprintf( wfp, "UNBIND\n" );
39         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
40         print_suffixes( wfp, be );
41         fprintf( wfp, "dn: %s\n", (conn->c_dn.bv_len ? conn->c_dn.bv_val : "") );
42         fclose( wfp );
43
44         /* no response to unbind */
45         fclose( rfp );
46
47         return 0;
48 }