]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
Fix maxDeref directive
[openldap] / servers / slapd / controls.c
index 74fadeabba7dbc8654376f2b9379add800e95fb1..37361cb47cde7e2493b63fdea4aec6e0afb12cda 100644 (file)
@@ -17,6 +17,7 @@
 #include "../../libraries/liblber/lber-int.h"
 
 char *supportedControls[] = {
+       LDAP_CONTROL_MANAGEDSAIT,
        NULL
 };
 
@@ -32,6 +33,7 @@ int get_ctrls(
        BerElement *ber = op->o_ber;
        LDAPControl ***ctrls = &op->o_ctrls;
        int rc = LDAP_SUCCESS;
+       char *errmsg = NULL;
 
        len = ber_pvt_ber_remaining(ber);
 
@@ -43,14 +45,16 @@ int get_ctrls(
 
        if(( tag = ber_peek_tag( ber, &len )) != LDAP_TAG_CONTROLS ) {
                if( tag == LBER_ERROR ) {
-                       rc = LDAP_PROTOCOL_ERROR;
+                       rc = -1;
+                       errmsg = "unexpected data in PDU";
                }
 
                goto return_results;
        }
 
        if( op->o_protocol < LDAP_VERSION3 ) {
-               rc = LDAP_PROTOCOL_ERROR;
+               rc = -1;
+               errmsg = "controls require LDAPv3";
                goto return_results;
        }
 
@@ -61,6 +65,7 @@ int get_ctrls(
 #if 0
        if( *ctrls == NULL ) {
                rc = LDAP_NO_MEMORY;
+               errmsg = "no memory";
                goto return_results;
        }
 #endif
@@ -94,6 +99,7 @@ int get_ctrls(
                        *ctrls = NULL;
 
                        rc = LDAP_NO_MEMORY;
+                       errmsg = "no memory";
                        goto return_results;
                }
 #endif
@@ -128,14 +134,16 @@ int get_ctrls(
                if( tag == LBER_ERROR ) {
                        *ctrls = NULL;
                        ldap_controls_free( tctrls );
-                       rc = LDAP_DECODING_ERROR;
+                       rc = -1;
+                       errmsg = "decoding controls error";
                        goto return_results;
                }
 
                if( tctrl->ldctl_iscritical &&
                        !charray_inlist( supportedControls, tctrl->ldctl_oid ) )
                {
-                       rc = LDAP_UNAVAILABLE_CRITICIAL_EXTENSION;
+                       rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+                       errmsg = "critical extension is unavailable ";
                        goto return_results;
                }
 
@@ -144,8 +152,32 @@ int get_ctrls(
 
 return_results:
        if( sendres && rc != LDAP_SUCCESS ) {
-               send_ldap_result( conn, op, rc, NULL, NULL );
+               if( rc == -1 ) {
+                       send_ldap_disconnect( conn, op, rc, errmsg );
+               } else {
+                       send_ldap_result( conn, op, rc,
+                               NULL, errmsg, NULL, NULL );
+               }
        }
 
        return rc;
 }
+
+
+int get_manageDSAit( Operation *op )
+{
+       int i;
+       if( op == NULL || op->o_ctrls == NULL ) {
+               return 0;
+       }
+
+       for( i=0; op->o_ctrls[i] != NULL; i++ ) {
+               if( strcmp( LDAP_CONTROL_MANAGEDSAIT, op->o_ctrls[i]->ldctl_oid )
+                       == 0 )
+               {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
\ No newline at end of file