3 * Copyright 1999 The OpenLDAP Foundation.
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
13 * LDAPv3 Extended Operation Request
14 * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
15 * requestName [0] LDAPOID,
16 * requestValue [1] OCTET STRING OPTIONAL
19 * LDAPv3 Extended Operation Response
20 * ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
21 * COMPONENTS OF LDAPResult,
22 * responseName [10] LDAPOID OPTIONAL,
23 * response [11] OCTET STRING OPTIONAL
31 #include <ac/socket.h>
35 char *supportedExtensions[] = {
46 int rc = LDAP_SUCCESS;
48 struct berval reqdata;
52 Debug( LDAP_DEBUG_TRACE, "do_extended\n", 0, 0, 0 );
55 reqdata.bv_val = NULL;
57 if( op->o_protocol < LDAP_VERSION3 ) {
58 Debug( LDAP_DEBUG_ANY, "do_extended: protocol version (%d) too low\n",
59 op->o_protocol, 0 ,0 );
60 send_ldap_disconnect( conn, op,
61 LDAP_PROTOCOL_ERROR, "requires LDAPv3" );
66 if ( ber_scanf( op->o_ber, "a", &reqoid ) == LBER_ERROR ) {
67 Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
68 send_ldap_disconnect( conn, op,
69 LDAP_PROTOCOL_ERROR, "decoding error" );
74 if( !charray_inlist( supportedExtensions, reqoid ) ) {
75 Debug( LDAP_DEBUG_ANY, "do_extended: unsupported operation \"%s\"\n",
77 send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
78 NULL, "unsuppored extended operation", NULL, NULL );
82 tag = ber_peek_tag( op->o_ber, &len );
84 if( ber_peek_tag( op->o_ber, &len ) == LDAP_TAG_EXOP_REQ_VALUE ) {
85 if( ber_scanf( op->o_ber, "o", &reqdata ) != LBER_ERROR ) {
86 Debug( LDAP_DEBUG_ANY, "do_extended: ber_scanf failed\n", 0, 0 ,0 );
87 send_ldap_disconnect( conn, op,
88 LDAP_PROTOCOL_ERROR, "decoding error" );
94 if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
95 Debug( LDAP_DEBUG_ANY, "do_extended: get_ctrls failed\n", 0, 0 ,0 );
99 Debug( LDAP_DEBUG_ARGS, "do_extended: oid \"%s\"\n", reqoid, 0 ,0 );
101 send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
102 NULL, "unsupported extended operation", NULL, NULL );
105 if ( reqoid != NULL ) {
108 if ( reqdata.bv_val != NULL ) {
109 free( reqdata.bv_val );