From be097fc8cdce753e36ca2e97349babe8bd00c019 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 4 May 2005 20:24:48 +0000 Subject: [PATCH] Add ldap_turn(3) and ldap_turn_s(3). --- include/ldap.h | 26 +++++++++- libraries/libldap/Makefile.in | 4 +- libraries/libldap/turn.c | 88 +++++++++++++++++++++++++++++++++ libraries/libldap_r/Makefile.in | 4 +- 4 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 libraries/libldap/turn.c diff --git a/include/ldap.h b/include/ldap.h index 849f054b25..c03d8d71ee 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -312,6 +312,8 @@ typedef struct ldapcontrol { #define LDAP_EXOP_X_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" #define LDAP_EXOP_X_CANCEL "1.3.6.1.1.8" +#define LDAP_EXOP_X_TURN "1.3.6.1.4.1.4203.666.6.4" + /* LDAP Grouping of Related Operations *//* a work in progress */ #ifdef LDAP_DEVEL #define LDAP_X_GROUPING_BASE "1.3.6.1.4.1.4203.666.10.3" @@ -1838,12 +1840,32 @@ ldap_cancel LDAP_P(( LDAP *ld, int *msgidp )); LDAP_F( int ) -ldap_cancel_s LDAP_P(( - LDAP *ld, +ldap_cancel_s LDAP_P(( LDAP *ld, int cancelid, LDAPControl **sctrl, LDAPControl **cctrl )); +/* + * LDAP Turn Extended Operation + * in turn.c + */ +#define LDAP_API_FEATURE_TURN 1000 + +LDAP_F( int ) +ldap_turn LDAP_P(( LDAP *ld, + int mutual, + LDAP_CONST char* identifier, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp )); + +LDAP_F( int ) +ldap_turn_s LDAP_P(( LDAP *ld, + int mutual, + LDAP_CONST char* identifier, + LDAPControl **sctrl, + LDAPControl **cctrl )); + /* * LDAP Server Side Sort * in sortctrl.c diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in index 42e47dab10..47d81ddc07 100644 --- a/libraries/libldap/Makefile.in +++ b/libraries/libldap/Makefile.in @@ -26,7 +26,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \ request.c os-ip.c url.c sortctrl.c vlvctrl.c \ init.c options.c print.c string.c util-int.c schema.c \ charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \ - groupings.c txn.c ppolicy.c + turn.c groupings.c txn.c ppolicy.c OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ controls.lo messages.lo references.lo extended.lo cyrus.lo \ @@ -37,7 +37,7 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \ - groupings.lo txn.lo ppolicy.lo + turn.lo groupings.lo txn.lo ppolicy.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries diff --git a/libraries/libldap/turn.c b/libraries/libldap/turn.c new file mode 100644 index 0000000000..085a4dc24b --- /dev/null +++ b/libraries/libldap/turn.c @@ -0,0 +1,88 @@ +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* ACKNOWLEDGEMENTS: + * This program was orignally developed by Kurt D. Zeilenga for inclusion in + * OpenLDAP Software. + */ + +/* + * LDAPv3 Turn Operation Request + */ + +#include "portable.h" + +#include +#include + +#include +#include +#include + +#include "ldap-int.h" +#include "ldap_log.h" + +int +ldap_turn( + LDAP *ld, + int mutual, + LDAP_CONST char* identifier, + LDAPControl **sctrls, + LDAPControl **cctrls, + int *msgidp ) +{ + BerElement *turnvalber = NULL; + struct berval *turnvalp = NULL; + int rc; + + turnvalber = ber_alloc_t( LBER_USE_DER ); + if( mutual ) { + ber_printf( turnvalber, "{bs}", mutual, identifier ); + } else { + ber_printf( turnvalber, "{s}", identifier ); + } + ber_flatten( turnvalber, &turnvalp ); + + rc = ldap_extended_operation( ld, LDAP_EXOP_X_TURN, + turnvalp, sctrls, cctrls, msgidp ); + ber_free( turnvalber, 1 ); + return rc; +} + +int +ldap_turn_s( + LDAP *ld, + int mutual, + LDAP_CONST char* identifier, + LDAPControl **sctrls, + LDAPControl **cctrls ) +{ + BerElement *turnvalber = NULL; + struct berval *turnvalp = NULL; + int rc; + + turnvalber = ber_alloc_t( LBER_USE_DER ); + if( mutual ) { + ber_printf( turnvalber, "{bs}", 0xFF, identifier ); + } else { + ber_printf( turnvalber, "{s}", identifier ); + } + ber_flatten( turnvalber, &turnvalp ); + + rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_TURN, + turnvalp, sctrls, cctrls, NULL, NULL ); + ber_free( turnvalber, 1 ); + return rc; +} + diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index 2e63c77fb1..09554ea9ad 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -28,7 +28,7 @@ XXSRCS = apitest.c test.c \ request.c os-ip.c url.c sortctrl.c vlvctrl.c \ init.c options.c print.c string.c util-int.c schema.c \ charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \ - groupings.c txn.c ppolicy.c + turn.c groupings.c txn.c ppolicy.c SRCS = threads.c rdwr.c tpool.c rq.c \ thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \ thr_pth.c thr_stub.c @@ -44,7 +44,7 @@ OBJS = threads.lo rdwr.lo tpool.lo rq.lo \ request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \ init.lo options.lo print.lo string.lo util-int.lo schema.lo \ charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \ - groupings.lo txn.lo ppolicy.lo + turn.lo groupings.lo txn.lo ppolicy.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -- 2.39.5