Back to index

openldap  2.4.31
unbind.c
Go to the documentation of this file.
00001 /* unbind.c - sock backend unbind function */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2007-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 /* ACKNOWLEDGEMENTS:
00017  * This work was initially developed by Brian Candler for inclusion
00018  * in OpenLDAP Software.
00019  */
00020 
00021 #include "portable.h"
00022 
00023 #include <stdio.h>
00024 
00025 #include <ac/socket.h>
00026 #include <ac/string.h>
00027 
00028 #include "slap.h"
00029 #include "back-sock.h"
00030 
00031 int
00032 sock_back_unbind(
00033     Operation        *op,
00034     SlapReply        *rs
00035 )
00036 {
00037        struct sockinfo      *si = (struct sockinfo *) op->o_bd->be_private;
00038        FILE                 *fp;
00039 
00040        if ( (fp = opensock( si->si_sockpath )) == NULL ) {
00041               send_ldap_error( op, rs, LDAP_OTHER,
00042                   "could not open socket" );
00043               return( -1 );
00044        }
00045 
00046        /* write out the request to the unbind process */
00047        fprintf( fp, "UNBIND\n" );
00048        fprintf( fp, "msgid: %ld\n", (long) op->o_msgid );
00049        sock_print_conn( fp, op->o_conn, si );
00050        sock_print_suffixes( fp, op->o_bd );
00051        fprintf( fp, "\n" );
00052 
00053        /* no response to unbind */
00054        fclose( fp );
00055 
00056        return 0;
00057 }