Add ldap_turn(3) and ldap_turn_s(3).

This commit is contained in:
Kurt Zeilenga 2005-05-04 20:24:48 +00:00
parent 1b080de8a8
commit be097fc8cd
4 changed files with 116 additions and 6 deletions

View File

@ -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 <draft-zeilenga-ldap-turn-xx.txt>
* 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

View File

@ -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

88
libraries/libldap/turn.c Normal file
View File

@ -0,0 +1,88 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* 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
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This program was orignally developed by Kurt D. Zeilenga for inclusion in
* OpenLDAP Software.
*/
/*
* LDAPv3 Turn Operation Request
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#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;
}

View File

@ -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