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