1 /* $NetBSD: unbind.c,v 1.1.1.3 2010/12/12 15:23:22 adam Exp $ */ 2 3 /* unbind.c - sock backend unbind function */ 4 /* OpenLDAP: pkg/ldap/servers/slapd/back-sock/unbind.c,v 1.3.2.3 2010/04/13 20:23:41 kurt Exp */ 5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 2007-2010 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18 /* ACKNOWLEDGEMENTS: 19 * This work was initially developed by Brian Candler for inclusion 20 * in OpenLDAP Software. 21 */ 22 23 #include "portable.h" 24 25 #include <stdio.h> 26 27 #include <ac/socket.h> 28 #include <ac/string.h> 29 30 #include "slap.h" 31 #include "back-sock.h" 32 33 int 34 sock_back_unbind( 35 Operation *op, 36 SlapReply *rs 37 ) 38 { 39 struct sockinfo *si = (struct sockinfo *) op->o_bd->be_private; 40 FILE *fp; 41 42 if ( (fp = opensock( si->si_sockpath )) == NULL ) { 43 send_ldap_error( op, rs, LDAP_OTHER, 44 "could not open socket" ); 45 return( -1 ); 46 } 47 48 /* write out the request to the unbind process */ 49 fprintf( fp, "UNBIND\n" ); 50 fprintf( fp, "msgid: %ld\n", (long) op->o_msgid ); 51 sock_print_conn( fp, op->o_conn, si ); 52 sock_print_suffixes( fp, op->o_bd ); 53 fprintf( fp, "\n" ); 54 55 /* no response to unbind */ 56 fclose( fp ); 57 58 return 0; 59 } 60