You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2018/12/01 22:06:11 UTC

[directory-ldap-api] branch master updated: o Split the AdDirSync control into two classes: one for the request, another for the response o Separated the controls in two categories: request/response. Some controls have a common OID for both type, which makes it difficult to know which part to use when encoding or decoding them.

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e2f611  o Split the AdDirSync control into two classes: one for the request, another for the response o Separated the controls in two categories: request/response. Some controls have a common OID for both type, which makes it difficult to know which part to use when encoding or decoding them.
4e2f611 is described below

commit 4e2f6115e6106252bfc8029f1511a695aa16c2e0
Author: Emmanuel Lecharny <el...@apache.org>
AuthorDate: Sat Dec 1 23:05:46 2018 +0100

    o Split the AdDirSync control into two classes: one for the request,
    another for the response
    o Separated the controls in two categories: request/response. Some
    controls have a common OID for both type, which makes it difficult to
    know which part to use when encoding or decoding them.
---
 .../api/dsmlv2/request/Dsmlv2Grammar.java          |   34 +-
 .../java/org/apache/directory/api/i18n/I18n.java   |   91 +-
 .../apache/directory/api/i18n/errors.properties    |    7 +-
 .../apache/directory/api/i18n/messages.properties  |    2 +
 .../api/osgi/ApiLdapExtrasCodecApiOsgiTest.java    |    4 +-
 .../api/osgi/ApiLdapExtrasCodecOsgiTest.java       |    2 +-
 .../codec/api/StandaloneLdapCodecServiceTest.java  |    7 +-
 .../ldap/codec/actions/controls/AddControl.java    |   13 +-
 .../api/ldap/codec/api/LdapApiService.java         |   68 +-
 .../directory/api/ldap/codec/api/LdapEncoder.java  |   23 +-
 .../ldap/codec/osgi/DefaultLdapCodecService.java   |  145 ++-
 .../proxiedauthz/ProxiedAuthzControlTest.java      |   12 +-
 .../search/entryChange/EntryChangeControlTest.java |   12 +-
 .../search/pagedSearch/PagedSearchControlTest.java |    6 +-
 .../persistentSearch/PSearchControlTest.java       |    4 +-
 .../search/subentries/SubEntryControlTest.java     |    4 +-
 .../controls/sort/SortRequestControlTest.java      |    8 +-
 .../controls/sort/SortResponseControlTest.java     |    4 +-
 .../ldap/codec/extended/ExtendedResponseTest.java  | 1001 ++++++--------------
 .../ldap/codec/standalone/CodecFactoryUtil.java    |  185 ++--
 .../codec/standalone/StandaloneLdapApiService.java |   55 +-
 .../ad/{AdDirSync.java => AdDirSyncRequest.java}   |   84 +-
 ...dDirSyncImpl.java => AdDirSyncRequestImpl.java} |   80 +-
 .../ad/{AdDirSync.java => AdDirSyncResponse.java}  |   38 +-
 ...DirSyncFlag.java => AdDirSyncResponseFlag.java} |   14 +-
 ...DirSyncImpl.java => AdDirSyncResponseImpl.java} |   40 +-
 .../api/ldap/extras/ExtrasBundleActivator.java     |   87 +-
 ...ntainer.java => AdDirSyncRequestContainer.java} |   52 +-
 ...corator.java => AdDirSyncRequestDecorator.java} |  137 ++-
 ...ncFactory.java => AdDirSyncRequestFactory.java} |   38 +-
 ...ncGrammar.java => AdDirSyncRequestGrammar.java} |  154 ++-
 ...esEnum.java => AdDirSyncRequestStatesEnum.java} |   36 +-
 ...tainer.java => AdDirSyncResponseContainer.java} |   50 +-
 ...orator.java => AdDirSyncResponseDecorator.java} |   70 +-
 ...cFactory.java => AdDirSyncResponseFactory.java} |   39 +-
 ...cGrammar.java => AdDirSyncResponseGrammar.java} |  118 +--
 ...sEnum.java => AdDirSyncResponseStatesEnum.java} |   28 +-
 .../controls/actions/AddControl.java               |    5 +-
 .../extras/controls/ad/AdDirSyncControlTest.java   |  212 -----
 .../controls/ad/AdDirSyncRequestControlTest.java   |  187 ++++
 .../controls/ad/AdDirSyncResponseControlTest.java  |  174 ++++
 41 files changed, 1610 insertions(+), 1720 deletions(-)

diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java
index 08dc01e..9aab276 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 
 package org.apache.directory.api.dsmlv2.request;
@@ -80,7 +80,7 @@ import org.xmlpull.v1.XmlPullParserException;
 public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
 {
     private LdapApiService codec = LdapApiServiceFactory.getSingleton();
-    
+
     /** Some literal */
     private static final String BATCH_REQUEST = "batchRequest";
     private static final String ABANDON_REQUEST = "abandonRequest";
@@ -222,7 +222,7 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
             String attributeValue;
             // requestID
             attributeValue = xpp.getAttributeValue( "", REQUEST_ID );
-            
+
             if ( attributeValue != null )
             {
                 abandonRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
@@ -234,10 +234,10 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
                     throw new XmlPullParserException( I18n.err( I18n.ERR_03000_REQUEST_ID_REQUIRED ), xpp, null );
                 }
             }
-            
+
             // abandonID
             attributeValue = xpp.getAttributeValue( "", "abandonID" );
-            
+
             if ( attributeValue != null )
             {
                 try
@@ -276,7 +276,7 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
             String attributeValue;
             // requestID
             attributeValue = xpp.getAttributeValue( "", REQUEST_ID );
-            
+
             if ( attributeValue != null )
             {
                 addRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
@@ -288,10 +288,10 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
                     throw new XmlPullParserException( I18n.err( I18n.ERR_03000_REQUEST_ID_REQUIRED ), xpp, null );
                 }
             }
-            
+
             // dn
             attributeValue = xpp.getAttributeValue( "", "dn" );
-            
+
             if ( attributeValue != null )
             {
                 try
@@ -372,7 +372,7 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
 
                 // Getting the value
                 String nextText = xpp.nextText();
-                
+
                 if ( !Strings.isEmpty( nextText ) )
                 {
                     try
@@ -1850,17 +1850,17 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
             try
             {
                 ExprNode exprNode = searchRequestDecorator.getFilterNode();
-                
+
                 if ( exprNode == null )
                 {
                     throw new IllegalStateException( I18n.err( I18n.ERR_03041_NO_FILTER_ELEMENT ) );
                 }
-                
+
                 searchRequest.setFilter( exprNode );
             }
             catch ( LdapSchemaException lse )
             {
-                
+
             }
         }
     };
@@ -1962,7 +1962,7 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
 
                 // Getting the value
                 String nextText = xpp.nextText();
-                
+
                 if ( !Strings.isEmpty( nextText ) )
                 {
                     if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
@@ -2008,7 +2008,7 @@ public final class Dsmlv2Grammar extends AbstractGrammar implements Grammar
                     throw new XmlPullParserException( I18n.err( I18n.ERR_03034_INCORRECT_TYPE_VALUE ), xpp, null );
                 }
 
-                control = codec.newControl( codec.newControl( attributeValue ) );
+                control = codec.newControl( codec.newRequestControl( attributeValue ) );
                 ( ( Request ) container.getBatchRequest().getCurrentRequest() ).addControl( control );
             }
             else
diff --git a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
index 8dd8a3e..fa18f0e 100644
--- a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
@@ -63,7 +63,7 @@ public enum I18n
 
     //     grammar                      1200 -  1299
     ERR_01200_BAD_TRANSITION_FROM_STATE( "ERR_01200_BAD_TRANSITION_FROM_STATE" ),
-    
+
     //     tlv                          1300 -  1399
     ERR_01300_CANNOT_PUT_PDU_IN_NULL_BUFFER( "ERR_01300_CANNOT_PUT_PDU_IN_NULL_BUFFER" ),
     ERR_01301_PDU_BUFFER_SIZE_TOO_SMALL( "ERR_01301_PDU_BUFFER_SIZE_TOO_SMALL" ),
@@ -81,7 +81,7 @@ public enum I18n
     ERR_02003_LINE_COLUMN( "ERR_02003_LINE_COLUMN" ),
     ERR_02004_MISSING_REQUEST_ID( "ERR_02004_MISSING_REQUEST_ID" ),
     ERR_02005_INTERNAL_ERROR( "ERR_02005_INTERNAL_ERROR" ),
-    
+
     // api-dsml-parser                  3000-3999
     ERR_03000_REQUEST_ID_REQUIRED( "ERR_03000_REQUEST_ID_REQUIRED" ),
     ERR_03001_DN_ATTRIBUTE_REQUIRED( "ERR_03001_DN_ATTRIBUTE_REQUIRED" ),
@@ -208,7 +208,7 @@ public enum I18n
 
     //     template                     4200-4300
     // None
-    
+
     // api-ldap-codec-core          5000-5999
     //     <>                           5000-5099
     ERR_05000_NULL_REQUEST_NAME( "ERR_05000_NULL_REQUEST_NAME" ),
@@ -296,12 +296,12 @@ public enum I18n
     ERR_05308_CHANGE_ONLY_DECODING_ERROR( "ERR_05308_CHANGE_ONLY_DECODING_ERROR" ),
     ERR_05309_RETURN_ECS_DECODING_ERROR( "ERR_05309_RETURN_ECS_DECODING_ERROR" ),
     ERR_05310_INVALID_VISIBILITY_FLAG( "ERR_05310_INVALID_VISIBILITY_FLAG" ),
-    
+
     //     osgi                         5400-5499
     ERR_05400_CONTROL_ARGUMENT_WAS_NULL( "ERR_05400_CONTROL_ARGUMENT_WAS_NULL" ),
     ERR_05401_FIGURE_OUT_HOW_TO_TRANSFORM( "ERR_05401_FIGURE_OUT_HOW_TO_TRANSFORM" ),
     ERR_05402_UNABLE_TO_ENCODE_RESPONSE_VALUE( "ERR_05402_UNABLE_TO_ENCODE_RESPONSE_VALUE" ),
-    
+
     //     search                       5500-5599
     ERR_05500_NULL_MATCHING_RULE_AND_TYPE( "ERR_05500_NULL_MATCHING_RULE_AND_TYPE" ),
     ERR_05501_MORE_THAN_ONE_FILTER_FOR_NOT_FILTER( "ERR_05501_MORE_THAN_ONE_FILTER_FOR_NOT_FILTER" ),
@@ -310,7 +310,7 @@ public enum I18n
 
     // api-ldap-codec-standalone        6000-6999
     ERR_06000_FAILED_TO_LOAD_DEFAULT_CODEC_FACTORY( "ERR_06000_FAILED_TO_LOAD_DEFAULT_CODEC_FACTORY" ),
-    
+
     // api-ldap-extras-aci              7000-7999
     ERR_07000_FILTER( "ERR_07000_FILTER" ),
     ERR_07001_NULL_IDENTIFICATION_TAG( "ERR_07001_NULL_IDENTIFICATION_TAG" ),
@@ -322,6 +322,7 @@ public enum I18n
     //     <>                               8000-8099
     ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER( "ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER" ),
     ERR_08001_CANNOT_DECODE_REFRESH_DELETES( "ERR_08001_CANNOT_DECODE_REFRESH_DELETES" ),
+    ERR_08002_CANNOT_FIND_CONTROL_FACTORY( "ERR_08002_CANNOT_FIND_CONTROL_FACTORY" ),
 
     //     controls                         8100-8199
     ERR_08100_SYNC_REQUEST_VALUE_MODE_DECODING_FAILED( "ERR_08100_SYNC_REQUEST_VALUE_MODE_DECODING_FAILED" ),
@@ -329,8 +330,10 @@ public enum I18n
     ERR_08102_SYNC_STATE_VALUE_MODE_DECODING_FAILED( "ERR_08102_SYNC_STATE_VALUE_MODE_DECODING_FAILED" ),
     ERR_08103_BAD_CONTROL_CRITICALITY( "ERR_08103_BAD_CONTROL_CRITICALITY" ),
     ERR_08104_AD_DIR_SYNC_FLAG_DECODING_FAILURE( "ERR_08104_AD_DIR_SYNC_FLAG_DECODING_FAILURE" ),
-    ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR( "ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR" ), 
-    ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR( "ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR" ), 
+    ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR( "ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR" ),
+    ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR( "ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR" ),
+    ERR_08107_AD_DIR_SYNC_PARENTS_FIRST_DECODING_ERROR( "ERR_08107_AD_DIR_SYNC_PARENTS_FIRST_DECODING_ERROR" ),
+    ERR_08108_AD_DIR_SYNC_MAX_ATTRIBUTE_COUNT_DECODING_ERROR( "ERR_08107_AD_DIR_SYNC_MAX_ATTRIBUTE_COUNT_DECODING_ERROR" ),
 
     //     extended                         8200-8399
     ERR_08200_CANCELID_DECODING_FAILED( "ERR_08200_CANCELID_DECODING_FAILED" ),
@@ -388,10 +391,10 @@ public enum I18n
     //     intermediate                     9300 -  9399
     ERR_9300_UNEXPECTED_SYNCINFO( "ERR_9300_UNEXPECTED_SYNCINFO" ),
 
-    // api-ldap-extras-sp               10000-10999 
+    // api-ldap-extras-sp               10000-10999
     // None
 
-    // api-ldap-extras-trigger          11000-11999 
+    // api-ldap-extras-trigger          11000-11999
     ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL( "ERR_11000_TRIGGER_SPECIFICATION_INIT_WITH_NULL" ),
     ERR_11001_TRIGGER_SPECIFICATION_INIT_WITH_EPTY_SPEC_LIST( "ERR_11001_TRIGGER_SPECIFICATION_INIT_WITH_EPTY_SPEC_LIST" ),
     ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE( "ERR_11002_TRIGGER_SPECIFICATION_PARSER_FAILURE" ),
@@ -400,7 +403,7 @@ public enum I18n
     ERR_12000_CANNOT_PROCESS_EMPTY_DN( "ERR_12000_CANNOT_PROCESS_EMPTY_DN" ),
     ERR_12001_CANNOT_ADD_NODE_CHILD_EXISTS( "ERR_12001_CANNOT_ADD_NODE_CHILD_EXISTS" ),
     ERR_12002_CANNOT_ADD_NODE_ALREADY_EXISTS( "ERR_12002_CANNOT_ADD_NODE_ALREADY_EXISTS" ),
-    
+
     // api-ldap-model                   13000 - 13999
     ERR_13000_INVALID_LENGTH( "ERR_13000_INVALID_LENGTH" ),
     ERR_13001_INVALID_MAXOLEN( "ERR_13001_INVALID_MAXOLEN" ),
@@ -459,7 +462,7 @@ public enum I18n
     ERR_13111_NO_COMPARATOR_CANT_MOVE_AFTER( "ERR_13111_NO_COMPARATOR_CANT_MOVE_AFTER" ),
     ERR_13112_CANNOT_ACCESS_IF_BEFORE_FIRST( "ERR_13112_CANNOT_ACCESS_IF_BEFORE_FIRST" ),
     ERR_13113_CANNOT_ACCESS_IF_AFTER_LAST( "ERR_13113_CANNOT_ACCESS_IF_AFTER_LAST" ),
-    
+
     //     entry                            13200 - 13299
     ERR_13200_VALUE_CANT_BE_NORMALIZED( "ERR_13200_VALUE_CANT_BE_NORMALIZED" ),
     ERR_13201_EMPTY_OPTION_NOT_ALLOWED( "ERR_13201_EMPTY_OPTION_NOT_ALLOWED" ),
@@ -512,7 +515,7 @@ public enum I18n
     ERR_13248_CANNOT_READ_ENTRY( "ERR_13248_CANNOT_READ_ENTRY" ),
     ERR_13249_NO_COMPARATOR_FOR_AT( "ERR_13249_NO_COMPARATOR_FOR_AT" ),
     ERR_13250_VALUE_MISSING_AT_THE_END( "ERR_13250_VALUE_MISSING_AT_THE_END" ),
-    
+
     //     filter                           13300 - 13399
     ERR_13300_BAD_PLACE_HOLDERS_NUMBER( "ERR_13300_BAD_PLACE_HOLDERS_NUMBER" ),
     ERR_13301_NO_ORDERING_MR_FOR_AT( "ERR_13301_NO_ORDERING_MR_FOR_AT" ),
@@ -611,7 +614,7 @@ public enum I18n
     ERR_13473_MODDN_WITH_ATTRIBUTES( "ERR_13473_MODDN_WITH_ATTRIBUTES" ),
     ERR_13474_LINE_LENGTH_TOO_SHORT( "ERR_13474_LINE_LENGTH_TOO_SHORT" ),
     ERR_13475_UNKNOWN_ATTRIBUTETYPE( "ERR_13475_UNKNOWN_ATTRIBUTETYPE" ),
-    
+
     //     message                          13500 - 13599
     ERR_13500_UNDEFINED_CHANGETYPE( "ERR_13500_UNDEFINED_CHANGETYPE" ),
     ERR_13501_UNKNOWN_JNDI_SCOPE( "ERR_13501_UNKNOWN_JNDI_SCOPE" ),
@@ -813,7 +816,7 @@ public enum I18n
     ERR_13399_MRU_PARSING_FAILURE( "ERR_13399_MRU_PARSING_FAILURE" ),
     ERR_13400_MRU_DESC_PARSING_FAILURE( "ERR_13400_MRU_DESC_PARSING_FAILURE" ),
     ERR_13401_CANNOT_PARSE_NULL_NF( "ERR_13401_CANNOT_PARSE_NULL_NF" ),
-    ERR_13402_NF_PARSING_FAILURE( "ERR_13402_NF_PARSING_FAILURE" ), 
+    ERR_13402_NF_PARSING_FAILURE( "ERR_13402_NF_PARSING_FAILURE" ),
     ERR_13403_NF_DESC_PARSING_FAILURE( "ERR_13403_NF_DESC_PARSING_FAILURE" ),
     ERR_13404_CANNOT_PARSE_NULL_NORM( "ERR_13404_CANNOT_PARSE_NULL_NORM" ),
     ERR_13405_NORM_PARSING_FAILURE( "ERR_13405_NORM_PARSING_FAILURE" ),
@@ -998,7 +1001,7 @@ public enum I18n
     // The messages
     // asn1 api                         0-999
     // none
-    
+
     // asn1 ber                         1000-1999
     //     <>                           1000-1099
     MSG_01000_TAG_DECODED( "MSG_01000_TAG_DECODED" ),
@@ -1020,14 +1023,14 @@ public enum I18n
     MSG_01016_STOP_DECODING_NULL_TLV( "MSG_01016_STOP_DECODING_NULL_TLV" ),
     MSG_01017_END_DECODING( "MSG_01017_END_DECODING" ),
     MSG_01018_END_DECODING_NULL_TLV( "MSG_01018_END_DECODING_NULL_TLV" ),
-    
+
     //     actions                          1100-1199
     MSG_01100_INTEGER_VALUE( "MSG_01100_INTEGER_VALUE" ),
     MSG_01101_BITSTRING_VALUE( "MSG_01101_BITSTRING_VALUE" ),
-    
+
     //     grammar                          1200-1299
     // None
-    
+
     //     tlv                              1300-1399
     MSG_01300_BOOLEAN_0X00_0XFF( "MSG_01300_BOOLEAN_0X00_0XFF" ),
 
@@ -1036,7 +1039,7 @@ public enum I18n
     MSG_02001_FAILED_PROCESSING_REQUEST( "MSG_02001_FAILED_PROCESSING_REQUEST" ),
     MSG_02002_FAILED_TO_BIND( "MSG_02002_FAILED_TO_BIND" ),
     MSG_02003_ERROR( "MSG_02003_ERROR" ),
-    
+
     // api-dsml-parser                  3000-3999
     MSG_3000_FAILED_TO_CREATE_XSLT_TRANSFORMER( "MSG_3000_FAILED_TO_CREATE_XSLT_TRANSFORMER" ),
 
@@ -1118,7 +1121,7 @@ public enum I18n
     MSG_04172_REBIND_BIND_CONNECTION( "MSG_04172_REBIND_BIND_CONNECTION" ),
     MSG_04173_UNBIND_START_TLS( "MSG_04173_UNBIND_START_TLS" ),
     MSG_04174_CREATING_NEW_CONNECTION_TEMPLATE( "MSG_04174_CREATING_NEW_CONNECTION_TEMPLATE" ),
-    
+
     // api-ldap-codec-core              5000-5999
     //     <>                               5000-5099
     //     actions                          5100-5199
@@ -1210,7 +1213,7 @@ public enum I18n
 
     //     api                              5200-5299
     MSG_5200_DECODED_LDAP_MESSAGE( "MSG_5200_DECODED_LDAP_MESSAGE" ),
-    
+
     //     controls                         5300-5399
     MSG_05300_CHANGE_TYPE( "MSG_05300_CHANGE_TYPE" ),
     MSG_05301_PREVIOUS_DN( "MSG_05301_PREVIOUS_DN" ),
@@ -1226,10 +1229,10 @@ public enum I18n
 
     //     osgi                             5400-5499
     // none
-    
+
     //     search                           5500-5599
     // none
-    
+
     // api-ldap-codec-standalone        6000-6999
     MSG_06000_REGISTERED_CONTROL_FACTORY( "MSG_06000_REGISTERED_CONTROL_FACTORY" ),
     MSG_06001_REGISTERED_EXTENDED_OP_FACTORY( "MSG_06001_REGISTERED_EXTENDED_OP_FACTORY" ),
@@ -1246,7 +1249,7 @@ public enum I18n
     //     <>                               8000-8099
     MSG_08000_COOKIE( "MSG_08000_COOKIE" ),
     MSG_08001_REFRESH_DELETES( "MSG_08001_REFRESH_DELETES" ),
-    
+
     //     controls                         8100-8199
     MSG_08100_MODE( "MSG_08100_MODE" ),
     MSG_08101_FLAGS( "MSG_08101_FLAGS" ),
@@ -1256,7 +1259,9 @@ public enum I18n
     MSG_08105_SYNC_STATE_TYPE( "MSG_08105_SYNC_STATE_TYPE" ),
     MSG_08106_ENTRY_UUID( "MSG_08106_ENTRY_UUID" ),
     MSG_08107_VLV_REQUEST_CONTAINER_INITIALIZED( "MSG_08107_VLV_REQUEST_CONTAINER_INITIALIZED" ),
-    
+    MSG_08108_PARENTS_FIRST( "MSG_08108_PARENTS_FIRST" ),
+    MSG_08109_MAX_ATTRIBUTE_COUNT( "MSG_08109_MAX_ATTRIBUTE_COUNT" ),
+
     //     extended                         8200-8399
     MSG_08200_CANCEL_ID( "MSG_08200_CANCEL_ID" ),
     MSG_08201_CONTROL_OID( "MSG_08201_CONTROL_OID" ),
@@ -1287,13 +1292,13 @@ public enum I18n
     // api-ldap-extras-codec-api        9000-9999
     //     <>                               9000 -  9099
     // none
-    
+
     //     controls                         9100 -  9199
     // none
-    
+
     //     extended                         9200 -  9299
     // none
-    
+
     //     intermediate                     9300 -  9399
     // none
 
@@ -1316,21 +1321,21 @@ public enum I18n
     MSG_13104_CREATING_LIST_CURSOR( "MSG_13104_CREATING_LIST_CURSOR" ),
     MSG_13105_CREATING_SET_CURSOR( "MSG_13105_CREATING_SET_CURSOR" ),
     MSG_13106_CREATING_SINGLE_CURSOR( "MSG_13106_CREATING_SINGLE_CURSOR" ),
-    
+
     //     entry                            13200 - 13299
     MSG_13200_CANT_STORE_ATTRIBUTE( "MSG_13200_CANT_STORE_ATTRIBUTE" ),
     MSG_13201_DN_CANT_BE_NORMALIZED( "MSG_13201_DN_CANT_BE_NORMALIZED" ),
     MSG_13202_AT_IS_NULL( "MSG_13202_AT_IS_NULL" ),
     MSG_13203_MISSING_ATTRIBUTE_IN_ENTRY( "MSG_13203_MISSING_ATTRIBUTE_IN_ENTRY" ),
-    
+
     //     filter                           13300 - 13399
     // none
-    
+
     //     ldif                             13400 - 13499
     MSG_13400_LDIF_VERSION( "MSG_13400_LDIF_VERSION" ),
     MSG_13401_PARSED_NO_ENTRY( "MSG_13401_PARSED_NO_ENTRY" ),
     MSG_13402_PARSED_ONE_ENTRY( "MSG_13402_PARSED_ONE_ENTRY" ),
-    MSG_13403_PARSED_N_ENTRIES( "MSG_13403_PARSED_N_ENTRIES" ), 
+    MSG_13403_PARSED_N_ENTRIES( "MSG_13403_PARSED_N_ENTRIES" ),
     MSG_13404_READ_MODIF( "MSG_13404_READ_MODIF" ),
     MSG_13405_READ_ATTR( "MSG_13405_READ_ATTR" ),
     MSG_13406_READ_ENTRY( "MSG_13406_READ_ENTRY" ),
@@ -1345,12 +1350,12 @@ public enum I18n
 
     //     message                          13500 - 13599
     MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA( "MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA" ),
-    
+
     //     name                             13600 - 13699
     MSG_13700_FAILED_TO_NORMALIZE( "MSG_13700_FAILED_TO_NORMALIZE" ),
     MSG_13701_SYNTAX_VALID( "MSG_13701_SYNTAX_VALID" ),
     MSG_13702_REMOVED_FROM_REGISTRY( "MSG_13702_REMOVED_FROM_REGISTRY" ),
-    
+
     //     schema                           13700 - 13899
     MSG_13703_AT_WITHOUT_EQ_MR( "MSG_13703_AT_WITHOUT_EQ_MR" ),
     MSG_13704_CANT_FIND_AT_WITH_SUPERIOR( "MSG_13704_CANT_FIND_AT_WITH_SUPERIOR" ),
@@ -1406,17 +1411,17 @@ public enum I18n
     MSG_13754_COMPARING_NUMERIC_STRING_ORDERING( "MSG_13754_COMPARING_NUMERIC_STRING_ORDERING" ),
     MSG_13755_COMPARING_OBJECTS( "MSG_13755_COMPARING_OBJECTS" ),
     MSG_13756_LOOKED_UP_NAME( "MSG_13756_LOOKED_UP_NAME" ),
-    
+
     // api-ldap-net-mina                14000 - 14999
     MSG_14000_DECODING_PDU( "MSG_14000_DECODING_PDU" ),
     MSG_14001_NULL_BUFFER( "MSG_14001_NULL_BUFFER" ),
     MSG_14002_DECODED_LDAP_MESSAGE( "MSG_14002_DECODED_LDAP_MESSAGE" ),
     MSG_14003_ENCODED_LDAP_MESSAGE( "MSG_14003_ENCODED_LDAP_MESSAGE" ),
-    
+
     // api-ldap-schema-converter        15000 - 15999
     MSG_15000_NO_SCHEMA_DEFINED( "MSG_15000_NO_SCHEMA_DEFINED" ),
     MSG_15001_GENERATING_SCHEMA( "MSG_15001_GENERATING_SCHEMA" ),
-    
+
     // api-ldap-schema-data             16000 - 16999
     MSG_16000_BASE_PATH( "MSG_16000_BASE_PATH" ),
     MSG_16001_CREATING_DIR( "MSG_16001_CREATING_DIR" ),
@@ -1470,7 +1475,7 @@ public enum I18n
 
     /**
      * Creates a new instance of I18n.
-     * 
+     *
      * @param errorCode the error code
      */
     I18n( String errorCode )
@@ -1490,7 +1495,7 @@ public enum I18n
         return errorCode;
     }
 
-    
+
     /**
      *
      * Translate an error code with argument(s)
@@ -1527,11 +1532,11 @@ public enum I18n
 
                 sb.append( obj );
             }
-            
+
             return sb.append( ')' ).toString();
         }
     }
-    
+
 
     /**
      *
@@ -1568,7 +1573,7 @@ public enum I18n
 
                 sb.append( obj );
             }
-            
+
             return sb.append( ')' ).toString();
         }
     }
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
index 0aab4ff..010efa7 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
@@ -314,6 +314,7 @@ ERR_07004_PARSER_FAILURE_ACI_ITEM=Parser failure on ACIItem:\n\t{0}\nAntlr excep
 # api-ldap-extras-codec <>           8000-8099
 ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER=Cannot put a PDU in a null buffer !
 ERR_08001_CANNOR_DECODE_REFRESH_DELETES=failed to decode the refreshDeletes flag for SyncDoneValueControl
+ERR_08002_CANNOT_FIND_CONTROL_FACTORY=failed to find a control factory for control OID: {0}
 
 # api-ldap-extras-codec controls     8100-8199
 ERR_08100_SYNC_REQUEST_VALUE_MODE_DECODING_FAILED=failed to decode the mode for SyncRequestValueControl
@@ -321,8 +322,10 @@ ERR_08101_RELOAD_HINT_DECODING_FAILED=failed to decode the reloadHint flag for S
 ERR_08102_SYNC_STATE_VALUE_MODE_DECODING_FAILED=failed to decode the mode for SyncStateValueControl
 ERR_08103_BAD_CONTROL_CRITICALITY=The control criticality flag {0} is invalid: {1}. It should be 0 or 255
 ERR_08104_AD_DIR_SYNC_FLAG_DECODING_FAILURE=Error while decoding the AdDirSync flag, unknown value: {0}
-ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR=Error while decoding the AdDirSync flag: 
-ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR=Error while decoding the AdDirSync maxReturnLength: 
+ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR=Error while decoding the AdDirSync flag: {0}
+ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR=Error while decoding the AdDirSync maxReturnLength value: {0} 
+ERR_08107_AD_DIR_SYNC_PARENTS_FIRST_DECODING_ERROR=Error while decoding the AdDirSync parentsFirst value: {0}
+ERR_08108_AD_DIR_SYNC_MAX_ATTRIBUTE_COUNT_DECODING_ERROR=Error while decoding the AdDirSync maxAttributeCount value: {0}
 
 # api-ldap-extras-codec extended     8200-8399
 ERR_08200_CANCELID_DECODING_FAILED=failed to decode the cancelId, the value should be between 0 and 2^31-1, it is ''{0}''
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
index 1aba719..08402ce 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/messages.properties
@@ -275,6 +275,8 @@ MSG_08104_RELOAD_HINT=reloadHint = {0}
 MSG_08105_SYNC_STATE_TYPE=SyncStateType = {0}
 MSG_08106_ENTRY_UUID=entryUUID = {0}
 MSG_08107_VLV_REQUEST_CONTAINER_INITIALIZED=VirtualListViewRequestContainer initialized
+MSG_08108_PARENTS_FIRST=parentsFirst = {0}
+MSG_08109_MAX_ATTRIBUTE_COUNT=maxAttributeCount = {0}
 
 # api-ldap-extras-codec extended     8200-8399
 MSG_08200_CANCEL_ID=CancelId = {0}
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java b/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
index d7875ec..96eebe7 100644
--- a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
+++ b/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecApiOsgiTest.java
@@ -21,7 +21,7 @@ package org.apache.directory.api.osgi;
 
 
 import org.apache.directory.api.ldap.extras.controls.SynchronizationModeEnum;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequestImpl;
 import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeletedImpl;
 import org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHintsImpl;
 
@@ -62,7 +62,7 @@ public class ApiLdapExtrasCodecApiOsgiTest extends ApiOsgiTestBase
     protected void useBundleClasses() throws Exception
     {
         SynchronizationModeEnum.REFRESH_AND_PERSIST.getValue();
-        new AdDirSyncImpl().getOid();
+        new AdDirSyncRequestImpl().getOid();
         new AdPolicyHintsImpl().getOid();
         new AdShowDeletedImpl().getOid();
         new ChangeNotificationsImpl().getOid();
diff --git a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java b/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
index 58ec71f..da4871f 100644
--- a/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
+++ b/integ-osgi/src/test/java/org/apache/directory/api/osgi/ApiLdapExtrasCodecOsgiTest.java
@@ -52,7 +52,7 @@ public class ApiLdapExtrasCodecOsgiTest extends ApiOsgiTestBase
     @Override
     protected void useBundleClasses() throws Exception
     {
-        CodecControl<? extends Control> control = ldapApiService.newControl( PasswordPolicy.OID );
+        CodecControl<? extends Control> control = ldapApiService.newRequestControl( PasswordPolicy.OID );
         assertNotNull( control );
         assertTrue( control instanceof PasswordPolicyDecorator );
 
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java b/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
index 34198cd..9da8b43 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
@@ -56,7 +56,8 @@ public class StandaloneLdapCodecServiceTest
             + "org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory,"
             + "org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory,"
             + "org.apache.directory.api.ldap.codec.controls.sort.SortResponseFactory,"
-            + "org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncFactory,"
+            + "org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestFactory,"
+            + "org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncResponseFactory,"
             + "org.apache.directory.api.ldap.extras.controls.ad_impl.AdPolicyHintsFactory,"
             + "org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory,"
             + "org.apache.directory.api.ldap.extras.controls.changeNotifications_impl.ChangeNotificationsFactory,"
@@ -83,7 +84,7 @@ public class StandaloneLdapCodecServiceTest
                     + "org.apache.directory.api.ldap.extras.extended.ads_impl.storedProcedure.StoredProcedureFactory,"
                     + "org.apache.directory.api.ldap.extras.extended.ads_impl.whoAmI.WhoAmIFactory"
                     );
-        
+
         System
         .setProperty(
             StandaloneLdapApiService.INTERMEDIATE_RESPONSES_LIST,
@@ -102,7 +103,7 @@ public class StandaloneLdapCodecServiceTest
 
         assertTrue( codec.isControlRegistered( PasswordPolicy.OID ) );
 
-        CodecControl<? extends Control> control = codec.newControl( PasswordPolicy.OID );
+        CodecControl<? extends Control> control = codec.newRequestControl( PasswordPolicy.OID );
         assertNotNull( control );
         assertNotNull( codec );
     }
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/AddControl.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/AddControl.java
index b88b2ab..011887c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/AddControl.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/controls/AddControl.java
@@ -25,10 +25,11 @@ import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.api.asn1.ber.tlv.TLV;
 import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.api.ldap.codec.api.AbstractMessageDecorator;
+import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.Message;
+import org.apache.directory.api.ldap.model.message.Request;
 import org.apache.directory.api.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -91,8 +92,16 @@ public class AddControl extends GrammarAction<LdapMessageContainer<AbstractMessa
         }
 
         Message message = container.getMessage();
+        Control control;
 
-        Control control = container.getLdapCodecService().newControl( oidValue );
+        if ( message instanceof Request )
+        {
+            control = container.getLdapCodecService().newRequestControl( oidValue );
+        }
+        else
+        {
+            control = container.getLdapCodecService().newResponseControl( oidValue );
+        }
 
         message.addControl( control );
 
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
index b0607ba..4d1fda5 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapApiService.java
@@ -54,15 +54,24 @@ public interface LdapApiService
     // ------------------------------------------------------------------------
 
     /**
-     * Returns an Iterator over the OID Strings of registered controls.
+     * Returns an Iterator over the OID Strings of registered request controls.
      *
      * @return The registered control OID Strings
      */
-    Iterator<String> registeredControls();
+    Iterator<String> registeredRequestControls();
 
 
     /**
-     * Checks if a control has been registered.
+     * Returns an Iterator over the OID Strings of registered response controls.
+     *
+     * @return The registered control OID Strings
+     */
+    Iterator<String> registeredResponseControls();
+
+
+    /**
+     * Checks if a control has been registered. It will check in both the
+     * request and response control maps.
      *
      * @param oid The Control OID we are looking for
      * @return The OID of the control to check for registration
@@ -71,30 +80,57 @@ public interface LdapApiService
 
 
     /**
-     * Registers an {@link ControlFactory} with this service.
+     * Registers an request {@link ControlFactory} with this service.
      *
      * @param factory The control factory
-     * @return The registred control factory
+     * @return The registered control factory
      */
-    ControlFactory<?> registerControl( ControlFactory<?> factory );
+    ControlFactory<?> registerRequestControl( ControlFactory<?> factory );
 
 
     /**
-     * Unregisters an {@link ControlFactory} with this service.
+     * Registers an response {@link ControlFactory} with this service.
+     *
+     * @param factory The control factory
+     * @return The registered control factory
+     */
+    ControlFactory<?> registerResponseControl( ControlFactory<?> factory );
+
+
+    /**
+     * Unregisters a request {@link ControlFactory} with this service.
      *
      * @param oid The oid of the control the factory is associated with.
-     * @return The unregistred control factory
+     * @return The unregistered control factory
      */
-    ControlFactory<?> unregisterControl( String oid );
+    ControlFactory<?> unregisterRequestControl( String oid );
 
 
     /**
-     * Creates a new codec control decorator of the specified type.
+     * Unregisters a response {@link ControlFactory} with this service.
+     *
+     * @param oid The oid of the control the factory is associated with.
+     * @return The unregistered control factory
+     */
+    ControlFactory<?> unregisterResponseControl( String oid );
+
+
+    /**
+     * Creates a new request codec control decorator of the specified type.
+     *
+     * @param oid The OID of the new control to create.
+     * @return The newly created codec control.
+     */
+    CodecControl<? extends Control> newRequestControl( String oid );
+
+
+    /**
+     * Creates a new response codec control decorator of the specified type.
      *
      * @param oid The OID of the new control to create.
      * @return The newly created codec control.
      */
-    CodecControl<? extends Control> newControl( String oid );
+    CodecControl<? extends Control> newResponseControl( String oid );
 
 
     /**
@@ -127,9 +163,15 @@ public interface LdapApiService
 
 
     /**
-     * @return the controlFactories
+     * @return the request controlFactories
+     */
+    Map<String, ControlFactory<? extends Control>> getRequestControlFactories();
+
+
+    /**
+     * @return the response controlFactories
      */
-    Map<String, ControlFactory<? extends Control>> getControlFactories();
+    Map<String, ControlFactory<? extends Control>> getResponseControlFactories();
 
 
     // ------------------------------------------------------------------------
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
index 40ab1d9..8bc2226 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/LdapEncoder.java
@@ -53,6 +53,7 @@ import org.apache.directory.api.ldap.codec.factory.UnbindRequestFactory;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.Message;
 import org.apache.directory.api.ldap.model.message.Referral;
+import org.apache.directory.api.ldap.model.message.Request;
 import org.apache.directory.api.util.Strings;
 
 
@@ -164,7 +165,7 @@ public final class LdapEncoder
      * @throws EncoderException If the encoding failed
      */
     private static void encodeControlsReverse( Asn1Buffer buffer, LdapApiService codec,
-        Map<String, Control> controls, Iterator<String> iterator ) throws EncoderException
+        Map<String, Control> controls, Iterator<String> iterator, boolean isRequest ) throws EncoderException
     {
         if ( iterator.hasNext() )
         {
@@ -172,10 +173,24 @@ public final class LdapEncoder
             Control control = controls.get( iterator.next() );
 
             // Encode the remaining controls recursively
-            encodeControlsReverse( buffer, codec, controls, iterator );
+            encodeControlsReverse( buffer, codec, controls, iterator, isRequest );
 
             // Fetch the control's factory from the LdapApiService
-            ControlFactory<?> controlFactory = codec.getControlFactories().get( control.getOid() );
+            ControlFactory<?> controlFactory;
+
+            if ( isRequest )
+            {
+                controlFactory = codec.getRequestControlFactories().get( control.getOid() );
+            }
+            else
+            {
+                controlFactory = codec.getResponseControlFactories().get( control.getOid() );
+            }
+
+            if ( controlFactory == null )
+            {
+                throw new EncoderException( I18n.err( I18n.ERR_08002_CANNOT_FIND_CONTROL_FACTORY, control.getOid() ) );
+            }
 
             int start = buffer.getPos();
 
@@ -320,7 +335,7 @@ public final class LdapEncoder
 
         if ( ( controls != null ) && ( controls.size() > 0 ) )
         {
-            encodeControlsReverse( buffer, codec, controls, controls.keySet().iterator() );
+            encodeControlsReverse( buffer, codec, controls, controls.keySet().iterator(), message instanceof Request );
 
             // The controls tag
             BerValue.encodeSequence( buffer, ( byte ) LdapCodecConstants.CONTROLS_TAG, start );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
index 794d50d..a19b1a7 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/osgi/DefaultLdapCodecService.java
@@ -89,8 +89,11 @@ public class DefaultLdapCodecService implements LdapApiService
     /** A logger */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultLdapCodecService.class );
 
-    /** The map of registered {@link org.apache.directory.api.ldap.codec.api.ControlFactory}'s */
-    private Map<String, ControlFactory<? extends Control>> controlFactories = new HashMap<>();
+    /** The map of registered request {@link ControlFactory}'s */
+    private Map<String, ControlFactory<? extends Control>> requestControlFactories = new HashMap<>();
+
+    /** The map of registered response {@link ControlFactory}'s */
+    private Map<String, ControlFactory<? extends Control>> responseControlFactories = new HashMap<>();
 
     /** The map of registered {@link org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory}'s by request OID */
     private Map<String, ExtendedOperationFactory> extendedOperationFactories = new HashMap<>();
@@ -117,7 +120,7 @@ public class DefaultLdapCodecService implements LdapApiService
     private void loadStockControls()
     {
         ControlFactory<Cascade> cascadeFactory = new CascadeFactory( this );
-        controlFactories.put( cascadeFactory.getOid(), cascadeFactory );
+        requestControlFactories.put( cascadeFactory.getOid(), cascadeFactory );
 
         if ( LOG.isInfoEnabled() )
         {
@@ -125,7 +128,7 @@ public class DefaultLdapCodecService implements LdapApiService
         }
 
         ControlFactory<EntryChange> entryChangeFactory = new EntryChangeFactory( this );
-        controlFactories.put( entryChangeFactory.getOid(), entryChangeFactory );
+        responseControlFactories.put( entryChangeFactory.getOid(), entryChangeFactory );
 
         if ( LOG.isInfoEnabled() )
         {
@@ -133,23 +136,16 @@ public class DefaultLdapCodecService implements LdapApiService
         }
 
         ControlFactory<ManageDsaIT> manageDsaItFactory = new ManageDsaITFactory( this );
-        controlFactories.put( manageDsaItFactory.getOid(), manageDsaItFactory );
+        requestControlFactories.put( manageDsaItFactory.getOid(), manageDsaItFactory );
 
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, manageDsaItFactory.getOid() ) );
         }
 
-        ControlFactory<ProxiedAuthz> proxiedAuthzFactory = new ProxiedAuthzFactory( this );
-        controlFactories.put( proxiedAuthzFactory.getOid(), proxiedAuthzFactory );
-
-        if ( LOG.isInfoEnabled() )
-        {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, proxiedAuthzFactory.getOid() ) );
-        }
-
         ControlFactory<PagedResults> pageResultsFactory = new PagedResultsFactory( this );
-        controlFactories.put( pageResultsFactory.getOid(), pageResultsFactory );
+        requestControlFactories.put( pageResultsFactory.getOid(), pageResultsFactory );
+        responseControlFactories.put( pageResultsFactory.getOid(), pageResultsFactory );
 
         if ( LOG.isInfoEnabled() )
         {
@@ -157,23 +153,23 @@ public class DefaultLdapCodecService implements LdapApiService
         }
 
         ControlFactory<PersistentSearch> persistentSearchFactory = new PersistentSearchFactory( this );
-        controlFactories.put( persistentSearchFactory.getOid(), persistentSearchFactory );
+        requestControlFactories.put( persistentSearchFactory.getOid(), persistentSearchFactory );
 
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, persistentSearchFactory.getOid() ) );
         }
 
-        ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( this );
-        controlFactories.put( subentriesFactory.getOid(), subentriesFactory );
+        ControlFactory<ProxiedAuthz> proxiedAuthzFactory = new ProxiedAuthzFactory( this );
+        requestControlFactories.put( proxiedAuthzFactory.getOid(), proxiedAuthzFactory );
 
         if ( LOG.isInfoEnabled() )
         {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, subentriesFactory.getOid() ) );
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, proxiedAuthzFactory.getOid() ) );
         }
 
         ControlFactory<SortRequest> sortRequestFactory = new SortRequestFactory( this );
-        controlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
+        requestControlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
 
         if ( LOG.isInfoEnabled() )
         {
@@ -181,12 +177,20 @@ public class DefaultLdapCodecService implements LdapApiService
         }
 
         ControlFactory<SortResponse> sortResponseFactory = new SortResponseFactory( this );
-        controlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
+        responseControlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
 
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, sortResponseFactory.getOid() ) );
         }
+
+        ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( this );
+        requestControlFactories.put( subentriesFactory.getOid(), subentriesFactory );
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, subentriesFactory.getOid() ) );
+        }
     }
 
 
@@ -198,9 +202,38 @@ public class DefaultLdapCodecService implements LdapApiService
      * {@inheritDoc}
      */
     @Override
-    public ControlFactory<?> registerControl( ControlFactory<?> factory )
+    public ControlFactory<?> registerRequestControl( ControlFactory<?> factory )
+    {
+        return requestControlFactories.put( factory.getOid(), factory );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ControlFactory<?> registerResponseControl( ControlFactory<?> factory )
+    {
+        return responseControlFactories.put( factory.getOid(), factory );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ControlFactory<?> unregisterRequestControl( String oid )
+    {
+        return requestControlFactories.remove( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ControlFactory<?> unregisterResponseControl( String oid )
     {
-        return controlFactories.put( factory.getOid(), factory );
+        return responseControlFactories.remove( oid );
     }
 
 
@@ -208,9 +241,9 @@ public class DefaultLdapCodecService implements LdapApiService
      * {@inheritDoc}
      */
     @Override
-    public ControlFactory<?> unregisterControl( String oid )
+    public Iterator<String> registeredRequestControls()
     {
-        return controlFactories.remove( oid );
+        return Collections.unmodifiableSet( requestControlFactories.keySet() ).iterator();
     }
 
 
@@ -218,9 +251,9 @@ public class DefaultLdapCodecService implements LdapApiService
      * {@inheritDoc}
      */
     @Override
-    public Iterator<String> registeredControls()
+    public Iterator<String> registeredResponseControls()
     {
-        return Collections.unmodifiableSet( controlFactories.keySet() ).iterator();
+        return Collections.unmodifiableSet( responseControlFactories.keySet() ).iterator();
     }
 
 
@@ -230,7 +263,7 @@ public class DefaultLdapCodecService implements LdapApiService
     @Override
     public boolean isControlRegistered( String oid )
     {
-        return controlFactories.containsKey( oid );
+        return requestControlFactories.containsKey( oid ) | responseControlFactories.containsKey( oid );
     }
 
 
@@ -300,9 +333,26 @@ public class DefaultLdapCodecService implements LdapApiService
      * {@inheritDoc}
      */
     @Override
-    public CodecControl<? extends Control> newControl( String oid )
+    public CodecControl<? extends Control> newRequestControl( String oid )
+    {
+        ControlFactory<?> factory = requestControlFactories.get( oid );
+
+        if ( factory == null )
+        {
+            return new BasicControlDecorator( this, new OpaqueControl( oid ) );
+        }
+
+        return factory.newCodecControl();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public CodecControl<? extends Control> newResponseControl( String oid )
     {
-        ControlFactory<?> factory = controlFactories.get( oid );
+        ControlFactory<?> factory = responseControlFactories.get( oid );
 
         if ( factory == null )
         {
@@ -325,14 +375,14 @@ public class DefaultLdapCodecService implements LdapApiService
             throw new NullPointerException( I18n.err( I18n.ERR_05400_CONTROL_ARGUMENT_WAS_NULL ) );
         }
 
-        // protect agains being multiply decorated
+        // protect against being multiply decorated
         if ( control instanceof CodecControl )
         {
             return ( CodecControl<?> ) control;
         }
 
         @SuppressWarnings("rawtypes")
-        ControlFactory factory = controlFactories.get( control.getOid() );
+        ControlFactory factory = requestControlFactories.get( control.getOid() );
 
         if ( factory == null )
         {
@@ -365,7 +415,7 @@ public class DefaultLdapCodecService implements LdapApiService
     public Control fromJndiControl( javax.naming.ldap.Control control ) throws DecoderException
     {
         @SuppressWarnings("rawtypes")
-        ControlFactory factory = controlFactories.get( control.getID() );
+        ControlFactory factory = requestControlFactories.get( control.getID() );
 
         if ( factory == null )
         {
@@ -703,21 +753,40 @@ public class DefaultLdapCodecService implements LdapApiService
 
 
     /**
-     * @return the controlFactories
+     * {@inheritDoc}
+     */
+    @Override
+    public Map<String, ControlFactory<? extends Control>> getRequestControlFactories()
+    {
+        return requestControlFactories;
+    }
+
+
+    /**
+     * {@inheritDoc}
      */
     @Override
-    public Map<String, ControlFactory<? extends Control>> getControlFactories()
+    public Map<String, ControlFactory<? extends Control>> getResponseControlFactories()
+    {
+        return responseControlFactories;
+    }
+
+
+    /**
+     * @param requestControlFactories the request controlFactories to set
+     */
+    public void setRequestControlFactories( Map<String, ControlFactory<? extends Control>> requestControlFactories )
     {
-        return controlFactories;
+        this.requestControlFactories = requestControlFactories;
     }
 
 
     /**
-     * @param controlFactories the controlFactories to set
+     * @param responseControlFactories the response controlFactories to set
      */
-    public void setControlFactories( Map<String, ControlFactory<? extends Control>> controlFactories )
+    public void setResponseControlFactories( Map<String, ControlFactory<? extends Control>> responseControlFactories )
     {
-        this.controlFactories = controlFactories;
+        this.responseControlFactories = responseControlFactories;
     }
 
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzControlTest.java
index 4123824..e951cab 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/proxiedauthz/ProxiedAuthzControlTest.java
@@ -70,7 +70,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
@@ -102,7 +102,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
@@ -133,7 +133,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
@@ -209,7 +209,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
@@ -245,7 +245,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
@@ -280,7 +280,7 @@ public class ProxiedAuthzControlTest extends AbstractCodecServiceTest
         Asn1Buffer buffer = new Asn1Buffer();
 
         ControlFactory<ProxiedAuthz> factory =
-            ( ControlFactory<ProxiedAuthz> ) codec.getControlFactories().get( ProxiedAuthz.OID );
+            ( ControlFactory<ProxiedAuthz> ) codec.getRequestControlFactories().get( ProxiedAuthz.OID );
 
         factory.encodeValue( buffer, proxiedAuthz );
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeControlTest.java
index d7c32d0..4114d7c 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/entryChange/EntryChangeControlTest.java
@@ -81,7 +81,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -119,7 +119,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -155,7 +155,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -218,7 +218,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -310,7 +310,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -353,7 +353,7 @@ public class EntryChangeControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getControlFactories().get( EntryChange.OID );
+        EntryChangeFactory factory = ( EntryChangeFactory ) codec.getResponseControlFactories().get( EntryChange.OID );
         factory.encodeValue( asn1Buffer, entryChange );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedSearchControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedSearchControlTest.java
index 0c0e023..77e8b77 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedSearchControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/pagedSearch/PagedSearchControlTest.java
@@ -89,7 +89,7 @@ public class PagedSearchControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getControlFactories().get( PagedResults.OID );
+        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getRequestControlFactories().get( PagedResults.OID );
         factory.encodeValue( asn1Buffer, ctrl );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -194,7 +194,7 @@ public class PagedSearchControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getControlFactories().get( PagedResults.OID );
+        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getResponseControlFactories().get( PagedResults.OID );
         factory.encodeValue( asn1Buffer, ctrl );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
@@ -257,7 +257,7 @@ public class PagedSearchControlTest extends AbstractCodecServiceTest
         // Check the reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getControlFactories().get( PagedResults.OID );
+        PagedResultsFactory factory = ( PagedResultsFactory ) codec.getResponseControlFactories().get( PagedResults.OID );
         factory.encodeValue( asn1Buffer, ctrl );
 
         assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PSearchControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PSearchControlTest.java
index 2393aba..0088eaf 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PSearchControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/persistentSearch/PSearchControlTest.java
@@ -81,7 +81,7 @@ public class PSearchControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<PersistentSearch> factory =
-            ( ControlFactory<PersistentSearch> )codec.getControlFactories().get( PersistentSearch.OID );
+            ( ControlFactory<PersistentSearch> )codec.getRequestControlFactories().get( PersistentSearch.OID );
 
         factory.encodeValue( asn1Buffer, ctrl );
 
@@ -119,7 +119,7 @@ public class PSearchControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<PersistentSearch> factory =
-            ( ControlFactory<PersistentSearch> )codec.getControlFactories().get( PersistentSearch.OID );
+            ( ControlFactory<PersistentSearch> )codec.getRequestControlFactories().get( PersistentSearch.OID );
 
         factory.encodeValue( asn1Buffer, ctrl );
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubEntryControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubEntryControlTest.java
index 01a1a80..fef0b1d 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubEntryControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/search/subentries/SubEntryControlTest.java
@@ -78,7 +78,7 @@ public class SubEntryControlTest extends AbstractCodecServiceTest
         // Test reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        ControlFactory<Subentries> factory = ( ControlFactory<Subentries> )codec.getControlFactories().get( Subentries.OID );
+        ControlFactory<Subentries> factory = ( ControlFactory<Subentries> )codec.getRequestControlFactories().get( Subentries.OID );
 
         factory.encodeValue( asn1Buffer, subentries );
 
@@ -114,7 +114,7 @@ public class SubEntryControlTest extends AbstractCodecServiceTest
         // Test reverse encoding
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
-        ControlFactory<Subentries> factory = ( ControlFactory<Subentries> )codec.getControlFactories().get( Subentries.OID );
+        ControlFactory<Subentries> factory = ( ControlFactory<Subentries> )codec.getRequestControlFactories().get( Subentries.OID );
 
         factory.encodeValue( asn1Buffer, subentries );
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestControlTest.java
index 8805aba..23695fc 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestControlTest.java
@@ -128,7 +128,7 @@ public class SortRequestControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortRequest> factory =
-            ( ControlFactory<SortRequest> ) codec.getControlFactories().get( SortRequest.OID );
+            ( ControlFactory<SortRequest> ) codec.getRequestControlFactories().get( SortRequest.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
@@ -186,7 +186,7 @@ public class SortRequestControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortRequest> factory =
-            ( ControlFactory<SortRequest> ) codec.getControlFactories().get( SortRequest.OID );
+            ( ControlFactory<SortRequest> ) codec.getRequestControlFactories().get( SortRequest.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
@@ -226,7 +226,7 @@ public class SortRequestControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortRequest> factory =
-            ( ControlFactory<SortRequest> ) codec.getControlFactories().get( SortRequest.OID );
+            ( ControlFactory<SortRequest> ) codec.getRequestControlFactories().get( SortRequest.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
@@ -274,7 +274,7 @@ public class SortRequestControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortRequest> factory =
-            ( ControlFactory<SortRequest> ) codec.getControlFactories().get( SortRequest.OID );
+            ( ControlFactory<SortRequest> ) codec.getRequestControlFactories().get( SortRequest.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
index 6c773d2..86997a2 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseControlTest.java
@@ -70,7 +70,7 @@ public class SortResponseControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortResponse> factory =
-            ( ControlFactory<SortResponse> ) codec.getControlFactories().get( SortResponse.OID );
+            ( ControlFactory<SortResponse> ) codec.getResponseControlFactories().get( SortResponse.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
@@ -104,7 +104,7 @@ public class SortResponseControlTest extends AbstractCodecServiceTest
         Asn1Buffer asn1Buffer = new Asn1Buffer();
 
         ControlFactory<SortResponse> factory =
-            ( ControlFactory<SortResponse> ) codec.getControlFactories().get( SortResponse.OID );
+            ( ControlFactory<SortResponse> ) codec.getResponseControlFactories().get( SortResponse.OID );
 
         factory.encodeValue( asn1Buffer, control );
 
diff --git a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
index b9f6d1b..18c2b3d 100644
--- a/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
+++ b/ldap/codec/core/src/test/java/org/apache/directory/api/ldap/codec/extended/ExtendedResponseTest.java
@@ -21,8 +21,6 @@ package org.apache.directory.api.ldap.codec.extended;
 
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
 import java.util.Map;
@@ -60,56 +58,33 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of a full ExtendedResponse
      */
     @Test
-    public void testDecodeExtendedResponseSuccess()
+    public void testDecodeExtendedResponseSuccess() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x24 );
 
         stream.put( new byte[]
-            { 0x30, 0x22, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp ExtendedResponse, ...
-                0x78,
-                0x1D, // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [10] LDAPOID OPTIONAL,
-                ( byte ) 0x8A,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                // response [11] OCTET STRING OPTIONAL }
-                ( byte ) 0x8B,
-                0x05,
-                'v',
-                'a',
-                'l',
-                'u',
-                'e' } );
+            {
+                0x30, 0x22,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp ExtendedResponse, ...
+                  0x78, 0x1D,               // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                                            // response [11] OCTET STRING OPTIONAL }
+                    ( byte ) 0x8B, 0x05,
+                      'v', 'a', 'l', 'u', 'e'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -119,15 +94,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -140,22 +107,14 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         assertEquals( "value", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x24, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x24, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -163,88 +122,41 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of a full ExtendedResponse with controls
      */
     @Test
-    public void testDecodeExtendedResponseSuccessWithControls()
+    public void testDecodeExtendedResponseSuccessWithControls() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x41 );
+        ByteBuffer stream = ByteBuffer.allocate( 0x40 );
 
         stream.put( new byte[]
             {
-                0x30,
-                0x3F, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE {
-                //    ...,
-                //    extendedResp ExtendedResponse,
-                //    ...
-                0x78,
-                0x1D, // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
-                //   COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, //   LDAPResult ::= SEQUENCE {
-                //     resultCode ENUMERATED {
-                //         success (0), ...
-                //     },
-                0x04,
-                0x00, //     matchedDN LDAPDN,
-                0x04,
-                0x00, //     errorMessage LDAPString,
-                //     referral [3] Referral OPTIONAL }
-                ( byte ) 0x8A,
-                0x0D, //   responseName [10] LDAPOID OPTIONAL,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                ( byte ) 0x8B,
-                0x05, // response [11] OCTET STRING OPTIONAL }
-                'v',
-                'a',
-                'l',
-                'u',
-                'e',
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                '2',
-                '.',
-                '1',
-                '6',
-                '.',
-                '8',
-                '4',
-                '0',
-                '.',
-                '1',
-                '.',
-                '1',
-                '1',
-                '3',
-                '7',
-                '3',
-                '0',
-                '.',
-                '3',
-                '.',
-                '4',
-                '.',
-                '2' } );
+                0x30, 0x3E,                     // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,             // messageID MessageID
+                                                // CHOICE {
+                                                //    ...,
+                                                //    extendedResp ExtendedResponse,
+                                                //    ...
+                  0x78, 0x1D,                   // ExtendedResponse ::= [APPLICATION 23] SEQUENCE {
+                                                //   COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,           // LDAPResult ::= SEQUENCE {
+                                                // resultCode ENUMERATED {
+                                                // success (0), ...
+                                                // },
+                    0x04, 0x00,                 // matchedDN LDAPDN,
+                    0x04, 0x00,                 // errorMessage LDAPString,
+                                                // referral [3] Referral OPTIONAL }
+                                                // responseName [0] LDAPOID,
+                                                //     referral [3] Referral OPTIONAL }
+                    ( byte ) 0x8A, 0x0D,        //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                    ( byte ) 0x8B, 0x05,        // response [11] OCTET STRING OPTIONAL }
+                      'v', 'a', 'l', 'u', 'e',
+                    ( byte ) 0xA0, 0x1A,        // A control
+                      0x30, 0x18,
+                        0x04, 0x16,
+                          '1', '.', '2', '.', '8', '4', '0', '.', '1', '1', '3', '5', '5', '6',
+                          '.', '1', '.', '4', '.', '5', '2', '8'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -254,15 +166,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -281,27 +185,19 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
 
         @SuppressWarnings("unchecked")
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control> ) controls
-            .get( "2.16.840.1.113730.3.4.2" );
-        assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
+            .get( "1.2.840.113556.1.4.528" );
+        assertEquals( "1.2.840.113556.1.4.528", control.getOid() );
         assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x41, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x40, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -309,33 +205,27 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of a ExtendedRequest with no name
      */
     @Test
-    public void testDecodeExtendedRequestNoName()
+    public void testDecodeExtendedRequestNoName() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x0E );
 
         stream.put( new byte[]
-            { 0x30, 0x0C, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x07, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00 // errorMessage LDAPString,
-            // referral [3] Referral OPTIONAL }
-            // responseName [0] LDAPOID,
+            {
+                0x30, 0x0C,             // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,     // messageID MessageID
+                                        // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x07,           // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                        // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,   // LDAPResult ::= SEQUENCE {
+                                        // resultCode ENUMERATED {
+                                        // success (0), ...
+                                        // },
+                    0x04, 0x00,         // matchedDN LDAPDN,
+                    0x04, 0x00          // errorMessage LDAPString,
+                                        // referral [3] Referral OPTIONAL }
+                                        // responseName [0] LDAPOID,
         } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
@@ -346,15 +236,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponse extendedResponse = container.getMessage();
@@ -365,22 +247,14 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         assertEquals( "", extendedResponse.getLdapResult().getDiagnosticMessage() );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x0E, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x0E, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -388,63 +262,33 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of a ExtendedRequest with no name and a control
      */
     @Test
-    public void testDecodeExtendedRequestNoNameWithControls()
+    public void testDecodeExtendedRequestNoNameWithControls() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x2B );
+        ByteBuffer stream = ByteBuffer.allocate( 0x2A );
 
         stream.put( new byte[]
-            { 0x30,
-                0x29, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x07, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                0x32,
-                0x2E,
-                0x31,
-                0x36,
-                0x2E,
-                0x38,
-                0x34,
-                0x30,
-                0x2E,
-                0x31,
-                0x2E,
-                0x31,
-                0x31,
-                0x33,
-                0x37,
-                0x33,
-                0x30,
-                0x2E,
-                0x33,
-                0x2E,
-                0x34,
-                0x2E,
-                0x32 } );
+            {
+                0x30, 0x28,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x07,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0xA0, 0x1A,    // A control
+                    0x30, 0x18,
+                      0x04, 0x16,
+                        '1', '.', '2', '.', '8', '4', '0', '.', '1', '1', '3', '5', '5', '6',
+                        '.', '1', '.', '4', '.', '5', '2', '8'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -454,15 +298,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponse extendedResponse = container.getMessage();
@@ -478,49 +314,39 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         assertEquals( 1, controls.size() );
         @SuppressWarnings("unchecked")
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control> ) controls
-            .get( "2.16.840.1.113730.3.4.2" );
-        assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
+            .get( "1.2.840.113556.1.4.528" );
+        assertEquals( "1.2.840.113556.1.4.528", control.getOid() );
         assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x2B, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x2A, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
     /**
      * Test the decoding of an empty ExtendedResponse
      */
-    @Test
-    public void testDecodeExtendedResponseEmpty()
+    @Test( expected=DecoderException.class )
+    public void testDecodeExtendedResponseEmpty() throws DecoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-            { 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x00 // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-        } );
+            {
+                0x30, 0x05,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x00                // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+            } );
 
         stream.flip();
 
@@ -529,51 +355,37 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode a DelRequest PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-            fail( "We should never reach this point !!!" );
-        }
-        catch ( DecoderException de )
-        {
-            assertTrue( true );
-        }
+        ldapDecoder.decode( stream, container );
     }
 
 
     /**
      * Test the decoding of an ExtendedResponse with an empty ResponseName
      */
-    @Test
-    public void testDecodeExtendedResponseEmptyResponseName()
+    @Test( expected=DecoderException.class )
+    public void testDecodeExtendedResponseEmptyResponseName() throws DecoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x10 );
 
         stream.put( new byte[]
-            { 0x30, 0x0E, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x09, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x00 } );
+            {
+                0x30, 0x0E,                     // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,             // messageID MessageID
+                                                // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x09,                   // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                                // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,           // LDAPResult ::= SEQUENCE {
+                                                // resultCode ENUMERATED {
+                                                // success (0), ...
+                                                // },
+                    0x04, 0x00,                 // matchedDN LDAPDN,
+                    0x04, 0x00,                 // errorMessage LDAPString,
+                                                // referral [3] Referral OPTIONAL }
+                                                // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x00
+            } );
 
         stream.flip();
 
@@ -582,53 +394,38 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode a DelRequest PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-            fail( "We should never reach this point !!!" );
-        }
-        catch ( DecoderException de )
-        {
-            assertTrue( true );
-        }
+        ldapDecoder.decode( stream, container );
     }
 
 
     /**
      * Test the decoding of an ExtendedResponse with a bad responseName
      */
-    @Test
-    public void testDecodeExtendedResponseBadOIDResponseName()
+    @Test( expected=DecoderException.class )
+    public void testDecodeExtendedResponseBadOIDResponseName() throws DecoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x12 );
 
         stream.put( new byte[]
-            { 0x30, 0x10, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x0B, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x02,
-                'a',
-                'b' } );
+            {
+                0x30, 0x10,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x0B,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x02,
+                      'a', 'b'
+               } );
 
         stream.flip();
 
@@ -636,16 +433,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         LdapMessageContainer<ExtendedResponseDecorator<?>> container =
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
-        // Decode a DelRequest PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-            fail( "We should never reach this point !!!" );
-        }
-        catch ( DecoderException de )
-        {
-            assertTrue( true );
-        }
+        ldapDecoder.decode( stream, container );
     }
 
 
@@ -653,48 +441,30 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of an ExtendedResponse with no response
      */
     @Test
-    public void testDecodeExtendedResponseNoResponse()
+    public void testDecodeExtendedResponseNoResponse() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x1D );
 
         stream.put( new byte[]
-            { 0x30, 0x1B, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x16, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2', } );
+            {
+                0x30, 0x1B,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x16,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -704,15 +474,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -725,22 +487,14 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x1D, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x1D, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -748,79 +502,35 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of an ExtendedResponse with no response with controls
      */
     @Test
-    public void testDecodeExtendedResponseNoResponseWithControls()
+    public void testDecodeExtendedResponseNoResponseWithControls() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x3A );
+        ByteBuffer stream = ByteBuffer.allocate( 0x39 );
 
         stream.put( new byte[]
             {
-                0x30,
-                0x38, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x16, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                0x32,
-                0x2E,
-                0x31,
-                0x36,
-                0x2E,
-                0x38,
-                0x34,
-                0x30,
-                0x2E,
-                0x31,
-                0x2E,
-                0x31,
-                0x31,
-                0x33,
-                0x37,
-                0x33,
-                0x30,
-                0x2E,
-                0x33,
-                0x2E,
-                0x34,
-                0x2E,
-                0x32 } );
+                0x30, 0x37,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x16,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                  ( byte ) 0xA0, 0x1A,      // A control
+                    0x30, 0x18,
+                      0x04, 0x16,
+                        '1', '.', '2', '.', '8', '4', '0', '.', '1', '1', '3', '5', '5', '6',
+                        '.', '1', '.', '4', '.', '5', '2', '8'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -830,15 +540,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -857,27 +559,19 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
 
         @SuppressWarnings("unchecked")
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control> ) controls
-            .get( "2.16.840.1.113730.3.4.2" );
-        assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
+            .get( "1.2.840.113556.1.4.528" );
+        assertEquals( "1.2.840.113556.1.4.528", control.getOid() );
         assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x3A, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x39, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -885,51 +579,31 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * Test the decoding of an ExtendedResponse with an empty response
      */
     @Test
-    public void testDecodeExtendedResponseEmptyResponse()
+    public void testDecodeExtendedResponseEmptyResponse() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
         ByteBuffer stream = ByteBuffer.allocate( 0x1F );
 
         stream.put( new byte[]
-            { 0x30,
-                0x1D, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                ( byte ) 0x8B,
-                0x00 } );
+            {
+                0x30, 0x1D,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x18,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                    ( byte ) 0x8B, 0x00
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -939,15 +613,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -960,22 +626,14 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
         assertEquals( "", Strings.utf8ToString( extendedResponse.getResponseValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x1F, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x1F, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 
 
@@ -984,81 +642,36 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
      * controls
      */
     @Test
-    public void testDecodeExtendedResponseEmptyResponseWithControls()
+    public void testDecodeExtendedResponseEmptyResponseWithControls() throws DecoderException, EncoderException
     {
         Asn1Decoder ldapDecoder = new Asn1Decoder();
 
-        ByteBuffer stream = ByteBuffer.allocate( 0x3C );
+        ByteBuffer stream = ByteBuffer.allocate( 0x3B );
 
         stream.put( new byte[]
             {
-                0x30,
-                0x3A, // LDAPMessage ::= SEQUENCE {
-                0x02,
-                0x01,
-                0x01, // messageID MessageID
-                // CHOICE { ..., extendedResp Response, ...
-                0x78,
-                0x18, // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
-                // COMPONENTS OF LDAPResult,
-                0x0A,
-                0x01,
-                0x00, // LDAPResult ::= SEQUENCE {
-                // resultCode ENUMERATED {
-                // success (0), ...
-                // },
-                0x04,
-                0x00, // matchedDN LDAPDN,
-                0x04,
-                0x00, // errorMessage LDAPString,
-                // referral [3] Referral OPTIONAL }
-                // responseName [0] LDAPOID,
-                ( byte ) 0x8A,
-                0x0D,
-                '1',
-                '.',
-                '3',
-                '.',
-                '6',
-                '.',
-                '1',
-                '.',
-                '5',
-                '.',
-                '5',
-                '.',
-                '2',
-                ( byte ) 0x8B,
-                0x00,
-                ( byte ) 0xA0,
-                0x1B, // A control
-                0x30,
-                0x19,
-                0x04,
-                0x17,
-                0x32,
-                0x2E,
-                0x31,
-                0x36,
-                0x2E,
-                0x38,
-                0x34,
-                0x30,
-                0x2E,
-                0x31,
-                0x2E,
-                0x31,
-                0x31,
-                0x33,
-                0x37,
-                0x33,
-                0x30,
-                0x2E,
-                0x33,
-                0x2E,
-                0x34,
-                0x2E,
-                0x32 } );
+                0x30, 0x39,                 // LDAPMessage ::= SEQUENCE {
+                  0x02, 0x01, 0x01,         // messageID MessageID
+                                            // CHOICE { ..., extendedResp Response, ...
+                  0x78, 0x18,               // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+                                            // COMPONENTS OF LDAPResult,
+                    0x0A, 0x01, 0x00,       // LDAPResult ::= SEQUENCE {
+                                            // resultCode ENUMERATED {
+                                            // success (0), ...
+                                            // },
+                    0x04, 0x00,             // matchedDN LDAPDN,
+                    0x04, 0x00,             // errorMessage LDAPString,
+                                            // referral [3] Referral OPTIONAL }
+                                            // responseName [0] LDAPOID,
+                    ( byte ) 0x8A, 0x0D,    //   responseName [10] LDAPOID OPTIONAL,
+                      '1', '.', '3', '.', '6', '.', '1', '.', '5', '.', '5', '.', '2',
+                    ( byte ) 0x8B, 0x00,
+                  ( byte ) 0xA0, 0x1A,    // A control
+                    0x30, 0x18,
+                      0x04, 0x16,
+                        '1', '.', '2', '.', '8', '4', '0', '.', '1', '1', '3', '5', '5', '6',
+                        '.', '1', '.', '4', '.', '5', '2', '8'
+            } );
 
         String decodedPdu = Strings.dumpBytes( stream.array() );
         stream.flip();
@@ -1068,15 +681,7 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
             new LdapMessageContainer<ExtendedResponseDecorator<?>>( codec );
 
         // Decode the ExtendedResponse PDU
-        try
-        {
-            ldapDecoder.decode( stream, container );
-        }
-        catch ( DecoderException de )
-        {
-            de.printStackTrace();
-            fail( de.getMessage() );
-        }
+        ldapDecoder.decode( stream, container );
 
         // Check the decoded ExtendedResponse PDU
         ExtendedResponseDecorator<?> extendedResponse = container.getMessage();
@@ -1095,26 +700,18 @@ public class ExtendedResponseTest extends AbstractCodecServiceTest
 
         @SuppressWarnings("unchecked")
         CodecControl<Control> control = ( org.apache.directory.api.ldap.codec.api.CodecControl<Control> ) controls
-            .get( "2.16.840.1.113730.3.4.2" );
-        assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
+            .get( "1.2.840.113556.1.4.528" );
+        assertEquals( "1.2.840.113556.1.4.528", control.getOid() );
         assertEquals( "", Strings.dumpBytes( control.getValue() ) );
 
         // Check the encoding
-        try
-        {
-            ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
-
-            // Check the length
-            assertEquals( 0x3C, bb.limit() );
-
-            String encodedPdu = Strings.dumpBytes( bb.array() );
-
-            assertEquals( encodedPdu, decodedPdu );
-        }
-        catch ( EncoderException ee )
-        {
-            ee.printStackTrace();
-            fail( ee.getMessage() );
-        }
+        ByteBuffer bb = LdapEncoder.encodeMessage( codec, extendedResponse );
+
+        // Check the length
+        assertEquals( 0x3B, bb.limit() );
+
+        String encodedPdu = Strings.dumpBytes( bb.array() );
+
+        assertEquals( encodedPdu, decodedPdu );
     }
 }
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
index 2ed50bc..ea4f925 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
@@ -36,13 +36,14 @@ import org.apache.directory.api.ldap.codec.controls.search.persistentSearch.Pers
 import org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory;
 import org.apache.directory.api.ldap.codec.controls.sort.SortRequestFactory;
 import org.apache.directory.api.ldap.codec.controls.sort.SortResponseFactory;
-
-import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeleted;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
 import org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHints;
-import org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory;
+import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeleted;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestFactory;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncResponseFactory;
 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdPolicyHintsFactory;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
-import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncFactory;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory;
 import org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotifications;
 import org.apache.directory.api.ldap.extras.controls.changeNotifications_impl.ChangeNotificationsFactory;
 import org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModify;
@@ -102,179 +103,213 @@ public final class CodecFactoryUtil
 
     /**
      * Loads the Controls implement out of the box in the codec.
-     * 
-     * @param controlFactories The Control factories to use
+     *
+     * @param requestControlFactories The Request Control factories to use
+     * @param responseControlFactories The Response Control factories to use
      * @param apiService The LDAP Service instance to use
      */
-    public static void loadStockControls( Map<String, ControlFactory<?>> controlFactories, LdapApiService apiService )
+    public static void loadStockControls( Map<String, ControlFactory<?>> requestControlFactories,
+        Map<String, ControlFactory<?>> responseControlFactories, LdapApiService apiService )
     {
         // Standard controls
+        // Cascade
         ControlFactory<Cascade> cascadeFactory = new CascadeFactory( apiService );
-        controlFactories.put( cascadeFactory.getOid(), cascadeFactory );
+        requestControlFactories.put( cascadeFactory.getOid(), cascadeFactory );
 
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, cascadeFactory.getOid() ) );
         }
 
+        // EntryChange
         ControlFactory<EntryChange> entryChangeFactory = new EntryChangeFactory( apiService );
-        controlFactories.put( entryChangeFactory.getOid(), entryChangeFactory );
-        
+        responseControlFactories.put( entryChangeFactory.getOid(), entryChangeFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, entryChangeFactory.getOid() ) );
         }
 
+        // ManageDsaIT
         ControlFactory<ManageDsaIT> manageDsaITFactory = new ManageDsaITFactory( apiService );
-        controlFactories.put( manageDsaITFactory.getOid(), manageDsaITFactory );
-        
+        requestControlFactories.put( manageDsaITFactory.getOid(), manageDsaITFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, manageDsaITFactory.getOid() ) );
         }
 
-        ControlFactory<ProxiedAuthz> proxiedAuthzFactory = new ProxiedAuthzFactory( apiService );
-        controlFactories.put( proxiedAuthzFactory.getOid(), proxiedAuthzFactory );
-        
+        // pagedResults (both a request and response control)
+        ControlFactory<PagedResults> pagedResultsFactory = new PagedResultsFactory( apiService );
+        requestControlFactories.put( pagedResultsFactory.getOid(), pagedResultsFactory );
+        responseControlFactories.put( pagedResultsFactory.getOid(), pagedResultsFactory );
+
         if ( LOG.isInfoEnabled() )
         {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, proxiedAuthzFactory.getOid() ) );
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, pagedResultsFactory.getOid() ) );
         }
 
-        ControlFactory<PagedResults> pagedResultsFactory = new PagedResultsFactory( apiService );
-        controlFactories.put( pagedResultsFactory.getOid(), pagedResultsFactory );
-        
+        // Proxied
+        ControlFactory<ProxiedAuthz> proxiedAuthzFactory = new ProxiedAuthzFactory( apiService );
+        requestControlFactories .put( proxiedAuthzFactory.getOid(), proxiedAuthzFactory );
+
         if ( LOG.isInfoEnabled() )
         {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, pagedResultsFactory.getOid() ) );
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, proxiedAuthzFactory.getOid() ) );
         }
 
+        // PersistentSearch
         ControlFactory<PersistentSearch> persistentSearchFactory = new PersistentSearchFactory( apiService );
-        controlFactories.put( persistentSearchFactory.getOid(), persistentSearchFactory );
-        
+        requestControlFactories.put( persistentSearchFactory.getOid(), persistentSearchFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, persistentSearchFactory.getOid() ) );
         }
 
-        ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( apiService );
-        controlFactories.put( subentriesFactory.getOid(), subentriesFactory );
-        
-        if ( LOG.isInfoEnabled() )
-        {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, subentriesFactory.getOid() ) );
-        }
-        
+        // SortRequest
         ControlFactory<SortRequest> sortRequestFactory = new SortRequestFactory( apiService );
-        controlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
-        
+        requestControlFactories.put( sortRequestFactory.getOid(), sortRequestFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, sortRequestFactory.getOid() ) );
         }
 
+        // SortResponse
         ControlFactory<SortResponse> sortResponseFactory = new SortResponseFactory( apiService );
-        controlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
-        
+        responseControlFactories.put( sortResponseFactory.getOid(), sortResponseFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, sortResponseFactory.getOid() ) );
         }
 
+        // Subentries
+        ControlFactory<Subentries> subentriesFactory = new SubentriesFactory( apiService );
+        requestControlFactories.put( subentriesFactory.getOid(), subentriesFactory );
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, subentriesFactory.getOid() ) );
+        }
+
         // Extra controls
-        ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( apiService );
-        controlFactories.put( adDirSyncFactory.getOid(), adDirSyncFactory );
-        
+        // AdDirSync request
+        ControlFactory<AdDirSyncRequest> adDirSyncRequestFactory = new AdDirSyncRequestFactory( apiService );
+        requestControlFactories.put( adDirSyncRequestFactory.getOid(), adDirSyncRequestFactory );
+
+        if ( LOG.isInfoEnabled() )
+        {
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adDirSyncRequestFactory.getOid() ) );
+        }
+
+        // AdDirSync response
+        ControlFactory<AdDirSyncResponse> adDirSyncResponseFactory = new AdDirSyncResponseFactory( apiService );
+        responseControlFactories.put( adDirSyncResponseFactory.getOid(), adDirSyncResponseFactory );
+
         if ( LOG.isInfoEnabled() )
         {
-            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adDirSyncFactory.getOid() ) );
+            LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adDirSyncRequestFactory.getOid() ) );
         }
-        
+
+        // AdShowDelete
         ControlFactory<AdShowDeleted> adShowDeletedFactory = new AdShowDeletedFactory( apiService );
-        controlFactories.put( adShowDeletedFactory.getOid(), adShowDeletedFactory );
-        
+        requestControlFactories.put( adShowDeletedFactory.getOid(), adShowDeletedFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adShowDeletedFactory.getOid() ) );
         }
-        
+
+        // AdPolicyHints
         ControlFactory<AdPolicyHints> adPolicyHintsFactory = new AdPolicyHintsFactory( apiService );
-        controlFactories.put( adPolicyHintsFactory.getOid(), adPolicyHintsFactory );
-        
+        requestControlFactories.put( adPolicyHintsFactory.getOid(), adPolicyHintsFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adPolicyHintsFactory.getOid() ) );
         }
 
+        // ChangeNotification
         ControlFactory<ChangeNotifications> changeNotificationsFactory = new ChangeNotificationsFactory( apiService );
-        controlFactories.put( changeNotificationsFactory.getOid(), changeNotificationsFactory );
-        
+        requestControlFactories.put( changeNotificationsFactory.getOid(), changeNotificationsFactory );
+        responseControlFactories.put( changeNotificationsFactory.getOid(), changeNotificationsFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, changeNotificationsFactory.getOid() ) );
         }
 
+        // PermissiveModify
         ControlFactory<PermissiveModify> permissiveModifyFactory = new PermissiveModifyFactory( apiService );
-        controlFactories.put( permissiveModifyFactory.getOid(), permissiveModifyFactory );
-        
+        requestControlFactories.put( permissiveModifyFactory.getOid(), permissiveModifyFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, permissiveModifyFactory.getOid() ) );
         }
 
+        // PasswordPolicy (request and response)
         ControlFactory<PasswordPolicy> passwordPolicyFactory = new PasswordPolicyFactory( apiService );
-        controlFactories.put( passwordPolicyFactory.getOid(), passwordPolicyFactory );
-        
+        requestControlFactories.put( passwordPolicyFactory.getOid(), passwordPolicyFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, passwordPolicyFactory.getOid() ) );
         }
 
+        // SyncDoneValue
         ControlFactory<SyncDoneValue> syncDoneValueFactory = new SyncDoneValueFactory( apiService );
-        controlFactories.put( syncDoneValueFactory.getOid(), syncDoneValueFactory );
-        
+        responseControlFactories.put( syncDoneValueFactory.getOid(), syncDoneValueFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncDoneValueFactory.getOid() ) );
-        } 
+        }
 
+        // SyncRequestValue
         ControlFactory<SyncRequestValue> syncRequestValueFactory = new SyncRequestValueFactory( apiService );
-        controlFactories.put( syncRequestValueFactory.getOid(), syncRequestValueFactory );
-        
+        requestControlFactories.put( syncRequestValueFactory.getOid(), syncRequestValueFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncRequestValueFactory.getOid() ) );
         }
 
+        // SyncStateValue
         ControlFactory<SyncStateValue> syncStateValueFactory = new SyncStateValueFactory( apiService );
-        controlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );
-        
+        requestControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, syncStateValueFactory.getOid() ) );
         }
 
+        // TransactionSpecification
         ControlFactory<TransactionSpecification> transactionSpecificationFactory = new TransactionSpecificationFactory( apiService );
-        controlFactories.put( transactionSpecificationFactory.getOid(), transactionSpecificationFactory );
-        
+        requestControlFactories.put( transactionSpecificationFactory.getOid(), transactionSpecificationFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, transactionSpecificationFactory.getOid() ) );
         }
 
+        // VirtualListViewRequest
         ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory(
             apiService );
-        controlFactories.put( virtualListViewRequestFactory.getOid(), virtualListViewRequestFactory );
-        
+        requestControlFactories.put( virtualListViewRequestFactory.getOid(), virtualListViewRequestFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, virtualListViewRequestFactory.getOid() ) );
         }
 
+        // VirtualListViewResponse
         ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
             apiService );
-        controlFactories.put( virtualListViewResponseFactory.getOid(), virtualListViewResponseFactory );
-        
+        responseControlFactories.put( virtualListViewResponseFactory.getOid(), virtualListViewResponseFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, virtualListViewResponseFactory.getOid() ) );
@@ -295,7 +330,7 @@ public final class CodecFactoryUtil
      * <li>startTls</li>
      * <li>startTransaction</li>
      * </ul>
-     * 
+     *
      * @param extendendOperationsFactories The map of extended operation factories
      * @param apiService The LdapApiService to use
      */
@@ -320,7 +355,7 @@ public final class CodecFactoryUtil
 
         EndTransactionFactory endTransactionFactory = new EndTransactionFactory( apiService );
         extendendOperationsFactories.put( endTransactionFactory.getOid(), endTransactionFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, endTransactionFactory.getOid() ) );
@@ -328,7 +363,7 @@ public final class CodecFactoryUtil
 
         GracefulDisconnectFactory gracefulDisconnectFactory = new GracefulDisconnectFactory( apiService );
         extendendOperationsFactories.put( gracefulDisconnectFactory.getOid(), gracefulDisconnectFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, gracefulDisconnectFactory.getOid() ) );
@@ -336,7 +371,7 @@ public final class CodecFactoryUtil
 
         GracefulShutdownFactory gracefulShutdownFactory = new GracefulShutdownFactory( apiService );
         extendendOperationsFactories.put( gracefulShutdownFactory.getOid(), gracefulShutdownFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, gracefulShutdownFactory.getOid() ) );
@@ -344,7 +379,7 @@ public final class CodecFactoryUtil
 
         PasswordModifyFactory passwordModifyFactory = new PasswordModifyFactory( apiService );
         extendendOperationsFactories.put( passwordModifyFactory.getOid(), passwordModifyFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, passwordModifyFactory.getOid() ) );
@@ -352,7 +387,7 @@ public final class CodecFactoryUtil
 
         StartTlsFactory startTlsFactory = new StartTlsFactory( apiService );
         extendendOperationsFactories.put( startTlsFactory.getOid(), startTlsFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, startTlsFactory.getOid() ) );
@@ -360,7 +395,7 @@ public final class CodecFactoryUtil
 
         StartTransactionFactory startTransactionFactory = new StartTransactionFactory( apiService );
         extendendOperationsFactories.put( startTransactionFactory.getOid(), startTransactionFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, startTransactionFactory.getOid() ) );
@@ -368,7 +403,7 @@ public final class CodecFactoryUtil
 
         StoredProcedureFactory storedProcedureFactory = new StoredProcedureFactory( apiService );
         extendendOperationsFactories.put( storedProcedureFactory.getOid(), storedProcedureFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, storedProcedureFactory.getOid() ) );
@@ -376,7 +411,7 @@ public final class CodecFactoryUtil
 
         WhoAmIFactory whoAmIFactory = new WhoAmIFactory( apiService );
         extendendOperationsFactories.put( whoAmIFactory.getOid(), whoAmIFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, whoAmIFactory.getOid() ) );
@@ -389,7 +424,7 @@ public final class CodecFactoryUtil
      * <ul>
      * <li>syncInfovalue</li>
      * </ul>
-     * 
+     *
      * @param intermediateResponseFactories The map of intermediate response factories
      * @param apiService The LdapApiService to use
      */
@@ -398,7 +433,7 @@ public final class CodecFactoryUtil
     {
         SyncInfoValueFactory syncInfoValueFactory = new SyncInfoValueFactory( apiService );
         intermediateResponseFactories.put( syncInfoValueFactory.getOid(), syncInfoValueFactory );
-        
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06002_REGISTERED_INTERMEDIATE_FACTORY, syncInfoValueFactory.getOid() ) );
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
index 1acb200..3decb9b 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/StandaloneLdapApiService.java
@@ -23,6 +23,7 @@ package org.apache.directory.api.ldap.codec.standalone;
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.ControlFactory;
@@ -30,6 +31,7 @@ import org.apache.directory.api.ldap.codec.api.ExtendedOperationFactory;
 import org.apache.directory.api.ldap.codec.api.IntermediateResponseFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
 import org.apache.directory.api.ldap.codec.osgi.DefaultLdapCodecService;
+import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.util.Strings;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.slf4j.Logger;
@@ -86,13 +88,13 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
     /**
      * Creates a new instance of StandaloneLdapCodecService.
      * <br><br>
-     * The following pom configuration is intended for use by unit test running 
+     * The following pom configuration is intended for use by unit test running
      * tools like Maven's surefire:
      * <pre>
      *   &lt;properties&gt;
      *     &lt;codec.plugin.directory&gt;${project.build.directory}/pluginDirectory&lt;/codec.plugin.directory&gt;
      *   &lt;/properties&gt;
-     * 
+     *
      *   &lt;build&gt;
      *     &lt;plugins&gt;
      *       &lt;plugin&gt;
@@ -119,7 +121,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
      *           &lt;/systemPropertyVariables&gt;
      *         &lt;/configuration&gt;
      *       &lt;/plugin&gt;
-     *       
+     *
      *       &lt;plugin&gt;
      *         &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      *         &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
@@ -146,7 +148,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
      *     &lt;/plugins&gt;
      *   &lt;/build&gt;
      * </pre>
-     * 
+     *
      * @throws Exception If we had an issue initializing the LDAP service
      */
     public StandaloneLdapApiService() throws Exception
@@ -163,17 +165,18 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
      * @param intermediateResponses The list of intermediate responsess to store
      * @throws Exception If we had an issue with one of the two lists
      */
-    public StandaloneLdapApiService( List<String> controls, List<String> extendedOperations, 
+    public StandaloneLdapApiService( List<String> controls, List<String> extendedOperations,
             List<String> intermediateResponses ) throws Exception
     {
-        CodecFactoryUtil.loadStockControls( getControlFactories(), this );
+        CodecFactoryUtil.loadStockControls( getRequestControlFactories(), getResponseControlFactories(), this );
 
         CodecFactoryUtil.loadStockExtendedOperations( getExtendedOperationFactories(), this );
 
         CodecFactoryUtil.loadStockIntermediateResponses( getIntermediateResponseFactories(), this );
 
         // Load the controls
-        loadControls( controls );
+        loadControls( controls, getRequestControlFactories() );
+        loadControls( controls, getResponseControlFactories() );
 
         // Load the extended operations
         loadExtendedOperations( extendedOperations );
@@ -190,7 +193,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
                     Class.forName( DEFAULT_PROTOCOL_CODEC_FACTORY );
                 Constructor<? extends ProtocolCodecFactory> constructor =
                     clazz.getConstructor( LdapApiService.class );
-                
+
                 if ( constructor != null )
                 {
                     setProtocolCodecFactory( constructor.newInstance( this ) );
@@ -210,7 +213,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Parses the system properties to obtain the controls list.
-     * 
+     *
      * @return A list of controls
      */
     private static List<String> getControlsFromSystemProperties()
@@ -249,7 +252,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
      * Parses the system properties to obtain the extended operations.
      * Such extended operations are stored in the <b>apacheds.extendedOperations</b>
      * and <b>default.extendedOperation.requests</b> system properties.
-     * 
+     *
      * @return a list of extended operation
      */
     private static List<String> getExtendedOperationsFromSystemProperties()
@@ -288,7 +291,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
      * Parses the system properties to obtain the intermediate responses.
      * Such intermediate responses are stored in the <b>apacheds.intermediateResponses</b>
      * and <b>default.intermediateResponses.requests</b> system properties.
-     * 
+     *
      * @return a list of intermediate responses
      */
     private static List<String> getIntermediateResponsesFromSystemProperties()
@@ -312,18 +315,19 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads a list of controls from their FQCN.
-     * 
+     *
      * @param controlsList The list of controls to load
      * @throws Exception if a control could not be loaded
      */
-    private void loadControls( List<String> controlsList ) throws Exception
+    private void loadControls( List<String> controlsList, Map<String, ControlFactory<? extends Control>> controlFactories )
+        throws Exception
     {
         // Adding all controls
         if ( !controlsList.isEmpty() )
         {
             for ( String controlFQCN : controlsList )
             {
-                loadControl( controlFQCN );
+                loadControl( controlFQCN, controlFactories );
             }
         }
     }
@@ -331,19 +335,20 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads a control from its FQCN.
-     * 
+     *
      * @param controlFQCN The control FQCN
      * @throws Exception If the control could not be loaded
      */
-    private void loadControl( String controlFQCN ) throws Exception
+    private void loadControl( String controlFQCN, Map<String, ControlFactory<? extends Control>> controlFactories )
+        throws Exception
     {
-        if ( getControlFactories().containsKey( controlFQCN ) )
+        if ( controlFactories.containsKey( controlFQCN ) )
         {
             if ( LOG.isDebugEnabled() )
             {
                 LOG.debug( I18n.msg( I18n.MSG_06003_CONTROL_FACTORY_ALREADY_LOADED, controlFQCN ) );
             }
-            
+
             return;
         }
 
@@ -357,7 +362,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
         Constructor<?> constructor = clazz.getConstructor( types );
 
         ControlFactory<?> factory = ( ControlFactory<?> ) constructor.newInstance( this );
-        getControlFactories().put( factory.getOid(), factory );
+        controlFactories.put( factory.getOid(), factory );
 
         if ( LOG.isInfoEnabled() )
         {
@@ -368,7 +373,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads a list of extended operation from their FQCN
-     * 
+     *
      * @param extendedOperationsList The list of extended operations to load
      * @throws Exception If an extended operations cannot be loaded
      */
@@ -387,7 +392,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads an of extended operations from its FQCN
-     * 
+     *
      * @param extendedOperationFQCN The extended operations to load
      * @throws Exception If the extended operations cannot be loaded
      */
@@ -399,7 +404,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
             {
                 LOG.debug( I18n.msg( I18n.MSG_06005_EXTENDED_OP_FACTORY_ALREADY_LOADED, extendedOperationFQCN ) );
             }
-            
+
             return;
         }
 
@@ -426,7 +431,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads a list of intermediate responses from their FQCN
-     * 
+     *
      * @param intermediateResponsesList The list of intermediate response to load
      * @throws Exception If one of the intermediate response cannot be loaded
      */
@@ -445,7 +450,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
 
     /**
      * Loads an intermediate responses from its FQCN
-     * 
+     *
      * @param intermediateResponseFQCN The intermediate response to load
      * @throws Exception If the intermediate response cannot be loaded
      */
@@ -457,7 +462,7 @@ public class StandaloneLdapApiService extends DefaultLdapCodecService
             {
                 LOG.debug( I18n.msg( I18n.MSG_06006_INTERMEDIATE_FACTORY_ALREADY_LOADED, intermediateResponseFQCN ) );
             }
-            
+
             return;
         }
 
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequest.java
similarity index 50%
copy from ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
copy to ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequest.java
index 1986a90..b29669c 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequest.java
@@ -19,17 +19,13 @@
  */
 package org.apache.directory.api.ldap.extras.controls.ad;
 
-import java.util.EnumSet;
-import java.util.Set;
-
 import org.apache.directory.api.ldap.model.message.Control;
 
 
 /**
- * The DirSync control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
- * We use the same control for both the SearchRequest and the SearchResultDone. Here is the
- * ASN/1 description of the SearchRequest control :
- * 
+ * The DirSync request control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
+ * Here is the ASN/1 description of the SearchRequest control :
+ *
  * <pre>
  * Repl    Control ::= SEQUENCE {
  *     controlType             1.2.840.113556.1.4.841
@@ -37,89 +33,63 @@ import org.apache.directory.api.ldap.model.message.Control;
  *     criticality             TRUE
  * }
  * </pre>
- * 
- * the control value can be one of the two structures :
- * 
+ *
+ * the control value is :
+ *
  * <pre>
  * Client side :
  * realReplControlValue ::= SEQUENCE {
- *     flags                 integer
- *     maxBytes              integer
- *     cookie                OCTET STRING
+ *     parentsFirst            integer
+ *     maxAttributeCount       integer
+ *     cookie                  OCTET STRING
  * }
  * </pre>
- * 
- * or
- * 
- * <pre>
- * Server side :
- * realReplControlValue ::= SEQUENCE {
- *     flag                  integer
- *     maxReturnLength       integer
- *     cookie                OCTET STRING
- * }
- * </pre> 
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  *
  */
-public interface AdDirSync extends Control
+public interface AdDirSyncRequest extends Control
 {
     /** This control OID */
     String OID = "1.2.840.113556.1.4.841";
 
-
-    /**
-     * @return The maximum length of attributes to be returned
-     */
-    int getMaxReturnLength();
-
-
-    /**
-     * @param maxReturnLength The maximum length of attributes to be returned
-     */
-    void setMaxReturnLength( int maxReturnLength );
-
-
     /**
-     * @return The cookie used while processing the successive DirSync operations
+     * @return 1 if the parents of the children comes before their children
      */
-    byte[] getCookie();
+    int getParentsFirst();
 
 
     /**
-     * @param cookie The cookie to send to the server. It's the value found in the response control. Should be null
-     * for the first control.
+     * Tell the server that it should send the parents of the children before
+     * their children.
+     * NOTE: it should have been a boolean, it's an integer instead.
+     *
+     * @param parentsFirst When set to 1, will return the parents before children
      */
-    void setCookie( byte[] cookie );
+    void setParentsFirst( int parentsFirst );
 
 
     /**
-     * @return The flags returned by the server. Zero or more of :
-     * <ul>
-     * <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
-     * <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
-     * <li>LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000)(</li>
-     * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
-     * </ul>
+     * @return The maximum attribute count to be returned
      */
-    Set<AdDirSyncFlag> getFlags();
+    int getMaxAttributeCount();
 
 
     /**
-     * @param flags The flags to be set. See {@link EnumSet} for how to generate EnumSets.
+     * @param maxAttributeCount The maximum attribute count to be returned
      */
-    void setFlags( Set<AdDirSyncFlag> flags );
+    void setMaxAttributeCount( int maxAttributeCount );
 
 
     /**
-     * @param flag The flag to be added to the current collection of flags.
+     * @return The cookie used while processing the successive DirSync operations
      */
-    void addFlag( AdDirSyncFlag flag );
+    byte[] getCookie();
 
 
     /**
-     * @param flag The flag to be removed from the current collection of flags. 
+     * @param cookie The cookie to send to the server. It's the value found in the response control. Should be null
+     * for the first control.
      */
-    void removeFlag( AdDirSyncFlag flag );
+    void setCookie( byte[] cookie );
 }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestImpl.java
similarity index 64%
copy from ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
copy to ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestImpl.java
index f3c9269..8bf57a9 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestImpl.java
@@ -21,55 +21,42 @@
 package org.apache.directory.api.ldap.extras.controls.ad;
 
 import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.Set;
 
 import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
 import org.apache.directory.api.util.Strings;
 
 /**
- * The class implemnting the AdDirsSync interface
- * 
+ * The class implementing the AdDirsSync interface
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncImpl extends AbstractControl implements AdDirSync
+public class AdDirSyncRequestImpl extends AbstractControl implements AdDirSyncRequest
 {
-    /** Flags used to control return values (client-to-server) or indicate that there are more data to return (server-to-client) */
-    private Set<AdDirSyncFlag> flags = EnumSet.noneOf( AdDirSyncFlag.class );
-     
+    /** The parentsFirst value */
+    private int parentsFirst;
+
+    /** The maximum attribute count to return */
+    private int maxAttributeCount = 0;
 
-    /** The maximum number of attributes to return */
-    private int maxReturnLength = 0;
-    
     /** The DirSync cookie */
     private byte[] cookie;
 
     /**
      * Creates an instance of the DirSync control
      */
-    public AdDirSyncImpl()
+    public AdDirSyncRequestImpl()
     {
         super( OID, Boolean.TRUE );
     }
 
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Set<AdDirSyncFlag> getFlags()
-    {
-        return flags;
-    }
 
-    
     /**
      * {@inheritDoc}
      */
     @Override
-    public void setFlags( Set<AdDirSyncFlag> flags )
+    public int getParentsFirst()
     {
-        this.flags = flags;
+        return parentsFirst;
     }
 
 
@@ -77,19 +64,9 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
      * {@inheritDoc}
      */
     @Override
-    public void addFlag( AdDirSyncFlag flag )
+    public void setParentsFirst( int parentsFirst )
     {
-        flags.add( flag );
-    }
-    
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void removeFlag( AdDirSyncFlag flag )
-    {
-        flags.remove( flag );
+        this.parentsFirst = parentsFirst;
     }
 
 
@@ -97,9 +74,9 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
      * {@inheritDoc}
      */
     @Override
-    public int getMaxReturnLength()
+    public int getMaxAttributeCount()
     {
-        return maxReturnLength;
+        return maxAttributeCount;
     }
 
 
@@ -107,9 +84,9 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
      * {@inheritDoc}
      */
     @Override
-    public void setMaxReturnLength( int maxReturnLength )
+    public void setMaxAttributeCount( int maxAttributeCount )
     {
-        this.maxReturnLength = maxReturnLength;
+        this.maxAttributeCount = maxAttributeCount;
     }
 
 
@@ -139,8 +116,8 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
             this.cookie = Strings.EMPTY_BYTES;
         }
     }
-    
-    
+
+
     /**
      * @see Object#hashCode()
      */
@@ -149,8 +126,8 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
     {
         int h = super.hashCode();
 
-        h = h * 17 + AdDirSyncFlag.getBitmask( flags );
-        h = h * 17 + maxReturnLength;
+        h = h * 17 + parentsFirst;
+        h = h * 17 + maxAttributeCount;
 
         if ( cookie != null )
         {
@@ -175,16 +152,16 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
             return true;
         }
 
-        if ( !( other instanceof AdDirSync ) )
+        if ( !( other instanceof AdDirSyncRequest ) )
         {
             return false;
         }
 
-        AdDirSync otherControl = ( AdDirSync ) other;
+        AdDirSyncRequest otherControl = ( AdDirSyncRequest ) other;
 
-        return super.equals( other ) 
-            && ( maxReturnLength == otherControl.getMaxReturnLength() )
-            && ( flags.equals( otherControl.getFlags() ) )
+        return super.equals( other )
+            && ( maxAttributeCount == otherControl.getMaxAttributeCount() )
+            && ( parentsFirst == otherControl.getParentsFirst() )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) )
             && ( isCritical() == otherControl.isCritical() );
     }
@@ -201,9 +178,8 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
         sb.append( "    DirSync control :\n" );
         sb.append( "        oid : " ).append( getOid() ).append( '\n' );
         sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
-        sb.append( "        flags : 0x" ).append( Integer.toHexString( AdDirSyncFlag.getBitmask( flags ) ) )
-                        .append( ' ' ).append( flags.toString() ).append( "\n" );
-        sb.append( "        maxReturnLength : '" ).append( getMaxReturnLength() ).append( "'\n" );
+        sb.append( "        parentsFirst : " ).append( parentsFirst ).append( "\n" );
+        sb.append( "        maxAttributeCount : '" ).append( maxAttributeCount ).append( "'\n" );
         sb.append( "        cookie            : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
 
         return sb.toString();
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java
similarity index 78%
rename from ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
rename to ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java
index 1986a90..32cfa08 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java
@@ -26,10 +26,9 @@ import org.apache.directory.api.ldap.model.message.Control;
 
 
 /**
- * The DirSync control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
- * We use the same control for both the SearchRequest and the SearchResultDone. Here is the
- * ASN/1 description of the SearchRequest control :
- * 
+ * The DirSync response control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
+ * Here is the ASN/1 description of the SearchRequest control :
+ *
  * <pre>
  * Repl    Control ::= SEQUENCE {
  *     controlType             1.2.840.113556.1.4.841
@@ -37,33 +36,20 @@ import org.apache.directory.api.ldap.model.message.Control;
  *     criticality             TRUE
  * }
  * </pre>
- * 
- * the control value can be one of the two structures :
- * 
- * <pre>
- * Client side :
- * realReplControlValue ::= SEQUENCE {
- *     flags                 integer
- *     maxBytes              integer
- *     cookie                OCTET STRING
- * }
- * </pre>
- * 
- * or
- * 
+ *
+ * the control value is :
  * <pre>
- * Server side :
  * realReplControlValue ::= SEQUENCE {
  *     flag                  integer
  *     maxReturnLength       integer
  *     cookie                OCTET STRING
  * }
- * </pre> 
+ * </pre>
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  *
  */
-public interface AdDirSync extends Control
+public interface AdDirSyncResponse extends Control
 {
     /** This control OID */
     String OID = "1.2.840.113556.1.4.841";
@@ -103,23 +89,23 @@ public interface AdDirSync extends Control
      * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
      * </ul>
      */
-    Set<AdDirSyncFlag> getFlags();
+    Set<AdDirSyncResponseFlag> getFlags();
 
 
     /**
      * @param flags The flags to be set. See {@link EnumSet} for how to generate EnumSets.
      */
-    void setFlags( Set<AdDirSyncFlag> flags );
+    void setFlags( Set<AdDirSyncResponseFlag> flags );
 
 
     /**
      * @param flag The flag to be added to the current collection of flags.
      */
-    void addFlag( AdDirSyncFlag flag );
+    void addFlag( AdDirSyncResponseFlag flag );
 
 
     /**
-     * @param flag The flag to be removed from the current collection of flags. 
+     * @param flag The flag to be removed from the current collection of flags.
      */
-    void removeFlag( AdDirSyncFlag flag );
+    void removeFlag( AdDirSyncResponseFlag flag );
 }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFlag.java
similarity index 86%
rename from ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java
rename to ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFlag.java
index 54ab2e5..59caf75 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncFlag.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFlag.java
@@ -27,7 +27,7 @@ import java.util.Set;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum AdDirSyncFlag
+public enum AdDirSyncResponseFlag
 {
     /** The Object Security flag */
     LDAP_DIRSYNC_OBJECT_SECURITY( 0x0001, "Object Security" ),
@@ -53,7 +53,7 @@ public enum AdDirSyncFlag
      * @param value The AdDirSync integer value
      * @param description The AdDirSync description
      **/
-    AdDirSyncFlag( int value, String description )
+    AdDirSyncResponseFlag( int value, String description )
     {
         this.value = value;
         this.description = description;
@@ -84,10 +84,10 @@ public enum AdDirSyncFlag
      * @param value The integer value
      * @return a set of all flags associated with the integer value
      */
-    public static Set<AdDirSyncFlag> getFlags( int value )
+    public static Set<AdDirSyncResponseFlag> getFlags( int value )
     {
-        EnumSet<AdDirSyncFlag> result = EnumSet.noneOf( AdDirSyncFlag.class );
-        for ( AdDirSyncFlag flag : EnumSet.allOf( AdDirSyncFlag.class ) )
+        EnumSet<AdDirSyncResponseFlag> result = EnumSet.noneOf( AdDirSyncResponseFlag.class );
+        for ( AdDirSyncResponseFlag flag : EnumSet.allOf( AdDirSyncResponseFlag.class ) )
         {
             if ( ( flag.getValue() & value ) == flag.getValue() )
             {
@@ -103,11 +103,11 @@ public enum AdDirSyncFlag
      * @param flags The AdDirSync flags
      * @return a bitmask in integer form associated with the set of flags
      */
-    public static int getBitmask( Set<AdDirSyncFlag> flags )
+    public static int getBitmask( Set<AdDirSyncResponseFlag> flags )
     {
         int mask = 0;
         
-        for ( AdDirSyncFlag flag : flags )
+        for ( AdDirSyncResponseFlag flag : flags )
         {
             mask += flag.getValue();
         }
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java
similarity index 85%
rename from ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
rename to ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java
index f3c9269..5d8f5dd 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java
@@ -29,45 +29,45 @@ import org.apache.directory.api.util.Strings;
 
 /**
  * The class implemnting the AdDirsSync interface
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncImpl extends AbstractControl implements AdDirSync
+public class AdDirSyncResponseImpl extends AbstractControl implements AdDirSyncResponse
 {
     /** Flags used to control return values (client-to-server) or indicate that there are more data to return (server-to-client) */
-    private Set<AdDirSyncFlag> flags = EnumSet.noneOf( AdDirSyncFlag.class );
-     
+    private Set<AdDirSyncResponseFlag> flags = EnumSet.noneOf( AdDirSyncResponseFlag.class );
+
 
     /** The maximum number of attributes to return */
     private int maxReturnLength = 0;
-    
+
     /** The DirSync cookie */
     private byte[] cookie;
 
     /**
      * Creates an instance of the DirSync control
      */
-    public AdDirSyncImpl()
+    public AdDirSyncResponseImpl()
     {
         super( OID, Boolean.TRUE );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public Set<AdDirSyncFlag> getFlags()
+    public Set<AdDirSyncResponseFlag> getFlags()
     {
         return flags;
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void setFlags( Set<AdDirSyncFlag> flags )
+    public void setFlags( Set<AdDirSyncResponseFlag> flags )
     {
         this.flags = flags;
     }
@@ -77,17 +77,17 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
      * {@inheritDoc}
      */
     @Override
-    public void addFlag( AdDirSyncFlag flag )
+    public void addFlag( AdDirSyncResponseFlag flag )
     {
         flags.add( flag );
     }
-    
+
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void removeFlag( AdDirSyncFlag flag )
+    public void removeFlag( AdDirSyncResponseFlag flag )
     {
         flags.remove( flag );
     }
@@ -139,8 +139,8 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
             this.cookie = Strings.EMPTY_BYTES;
         }
     }
-    
-    
+
+
     /**
      * @see Object#hashCode()
      */
@@ -149,7 +149,7 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
     {
         int h = super.hashCode();
 
-        h = h * 17 + AdDirSyncFlag.getBitmask( flags );
+        h = h * 17 + AdDirSyncResponseFlag.getBitmask( flags );
         h = h * 17 + maxReturnLength;
 
         if ( cookie != null )
@@ -175,14 +175,14 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
             return true;
         }
 
-        if ( !( other instanceof AdDirSync ) )
+        if ( !( other instanceof AdDirSyncResponse ) )
         {
             return false;
         }
 
-        AdDirSync otherControl = ( AdDirSync ) other;
+        AdDirSyncResponse otherControl = ( AdDirSyncResponse ) other;
 
-        return super.equals( other ) 
+        return super.equals( other )
             && ( maxReturnLength == otherControl.getMaxReturnLength() )
             && ( flags.equals( otherControl.getFlags() ) )
             && ( Arrays.equals( cookie, otherControl.getCookie() ) )
@@ -201,7 +201,7 @@ public class AdDirSyncImpl extends AbstractControl implements AdDirSync
         sb.append( "    DirSync control :\n" );
         sb.append( "        oid : " ).append( getOid() ).append( '\n' );
         sb.append( "        critical : " ).append( isCritical() ).append( '\n' );
-        sb.append( "        flags : 0x" ).append( Integer.toHexString( AdDirSyncFlag.getBitmask( flags ) ) )
+        sb.append( "        flags : 0x" ).append( Integer.toHexString( AdDirSyncResponseFlag.getBitmask( flags ) ) )
                         .append( ' ' ).append( flags.toString() ).append( "\n" );
         sb.append( "        maxReturnLength : '" ).append( getMaxReturnLength() ).append( "'\n" );
         sb.append( "        cookie            : '" ).append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
index bc776b3..8dc74db 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
@@ -22,16 +22,18 @@ package org.apache.directory.api.ldap.extras;
 
 import org.apache.directory.api.ldap.codec.api.ControlFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeleted;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
 import org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHints;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
-import org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory;
+import org.apache.directory.api.ldap.extras.controls.ad.AdShowDeleted;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestFactory;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncResponseFactory;
 import org.apache.directory.api.ldap.extras.controls.ad_impl.AdPolicyHintsFactory;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdShowDeletedFactory;
 import org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotifications;
 import org.apache.directory.api.ldap.extras.controls.changeNotifications_impl.ChangeNotificationsFactory;
 import org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModify;
 import org.apache.directory.api.ldap.extras.controls.permissiveModify_impl.PermissiveModifyFactory;
-import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncFactory;
 import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
 import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory;
 import org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue;
@@ -74,8 +76,8 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
 
 /**
- * A BundleActivator for the ldap codec extras extension: extra ApacheDS and 
- * Apache Directory Studio specific controls and extended operations. 
+ * A BundleActivator for the ldap codec extras extension: extra ApacheDS and
+ * Apache Directory Studio specific controls and extended operations.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -164,18 +166,24 @@ public class ExtrasBundleActivator implements BundleActivator
 
         private void unregisterExtrasControls( LdapApiService codec )
         {
-            codec.unregisterControl( AdDirSync.OID );
-            codec.unregisterControl( AdShowDeleted.OID );
-            codec.unregisterControl( AdPolicyHints.OID );
-            codec.unregisterControl( ChangeNotifications.OID );
-            codec.unregisterControl( PasswordPolicy.OID );
-            codec.unregisterControl( PermissiveModify.OID );
-            codec.unregisterControl( SyncDoneValue.OID );
-            codec.unregisterControl( SyncRequestValue.OID );
-            codec.unregisterControl( SyncStateValue.OID );
-            codec.unregisterControl( TransactionSpecification.OID );
-            codec.unregisterControl( VirtualListViewRequest.OID );
-            codec.unregisterControl( VirtualListViewResponse.OID );
+            // Request controls
+            codec.unregisterRequestControl( AdDirSyncRequest.OID );
+            codec.unregisterRequestControl( AdPolicyHints.OID );
+            codec.unregisterRequestControl( AdShowDeleted.OID );
+            codec.unregisterRequestControl( ChangeNotifications.OID );
+            codec.unregisterRequestControl( PasswordPolicy.OID );
+            codec.unregisterRequestControl( PermissiveModify.OID );
+            codec.unregisterRequestControl( SyncRequestValue.OID );
+            codec.unregisterRequestControl( TransactionSpecification.OID );
+            codec.unregisterRequestControl( VirtualListViewRequest.OID );
+
+            // Response controls
+            codec.unregisterResponseControl( AdDirSyncRequest.OID );
+            codec.unregisterResponseControl( ChangeNotifications.OID );
+            codec.unregisterResponseControl( PasswordPolicy.OID );
+            codec.unregisterResponseControl( SyncDoneValue.OID );
+            codec.unregisterResponseControl( SyncStateValue.OID );
+            codec.unregisterResponseControl( VirtualListViewResponse.OID );
         }
 
 
@@ -201,42 +209,47 @@ public class ExtrasBundleActivator implements BundleActivator
          */
         private void registerExtrasControls( LdapApiService codec )
         {
-            ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( codec );
-            codec.registerControl( adDirSyncFactory );
-            
-            ControlFactory<AdShowDeleted> adDeletedFactory = new AdShowDeletedFactory( codec );
-            codec.registerControl( adDeletedFactory );
-            
+            ControlFactory<AdDirSyncRequest> adDirSyncRequestFactory = new AdDirSyncRequestFactory( codec );
+            codec.registerRequestControl( adDirSyncRequestFactory );
+
+            ControlFactory<AdDirSyncResponse> adDirSyncResponseFactory = new AdDirSyncResponseFactory( codec );
+            codec.registerResponseControl( adDirSyncResponseFactory );
+
             ControlFactory<AdPolicyHints> adPolicyHintsFactory = new AdPolicyHintsFactory( codec );
-            codec.registerControl( adPolicyHintsFactory );
-            
+            codec.registerRequestControl( adPolicyHintsFactory );
+
+            ControlFactory<AdShowDeleted> adShowDeletedFactory = new AdShowDeletedFactory( codec );
+            codec.registerRequestControl( adShowDeletedFactory );
+
             ControlFactory<ChangeNotifications> changeNotificationsFactory = new ChangeNotificationsFactory( codec );
-            codec.registerControl( changeNotificationsFactory );
+            codec.registerRequestControl( changeNotificationsFactory );
+            codec.registerResponseControl( changeNotificationsFactory );
 
             ControlFactory<PasswordPolicy> passwordPolicyFactory = new PasswordPolicyFactory( codec );
-            codec.registerControl( passwordPolicyFactory );
+            codec.registerRequestControl( passwordPolicyFactory );
+            codec.registerResponseControl( passwordPolicyFactory );
 
             ControlFactory<PermissiveModify> permissiveModifyFactory = new PermissiveModifyFactory( codec );
-            codec.registerControl( permissiveModifyFactory );
+            codec.registerRequestControl( permissiveModifyFactory );
 
             ControlFactory<SyncDoneValue> syncDoneValuefactory = new SyncDoneValueFactory( codec );
-            codec.registerControl( syncDoneValuefactory );
+            codec.registerResponseControl( syncDoneValuefactory );
 
             ControlFactory<SyncRequestValue> syncRequestValueFactory = new SyncRequestValueFactory( codec );
-            codec.registerControl( syncRequestValueFactory );
+            codec.registerRequestControl( syncRequestValueFactory );
 
             ControlFactory<SyncStateValue> syncStateValuefactory = new SyncStateValueFactory( codec );
-            codec.registerControl( syncStateValuefactory );
+            codec.registerResponseControl( syncStateValuefactory );
 
             ControlFactory<TransactionSpecification> transactionSpecificationfactory = new TransactionSpecificationFactory( codec );
-            codec.registerControl( transactionSpecificationfactory );
+            codec.registerRequestControl( transactionSpecificationfactory );
 
             ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory( codec );
-            codec.registerControl( virtualListViewRequestFactory );
+            codec.registerRequestControl( virtualListViewRequestFactory );
 
             ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
                 codec );
-            codec.registerControl( virtualListViewResponseFactory );
+            codec.registerResponseControl( virtualListViewResponseFactory );
         }
     }
 
@@ -252,8 +265,8 @@ public class ExtrasBundleActivator implements BundleActivator
             context, LdapApiService.class, ldapApiServiceTracker );
         serviceTracker.open();
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestContainer.java
similarity index 60%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestContainer.java
index 4263c17..30aebc0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestContainer.java
@@ -6,86 +6,86 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
 
 import org.apache.directory.api.asn1.ber.AbstractContainer;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
 
 
 /**
- * 
- * ASN.1 container for AD DirSync control.
+ *
+ * ASN.1 container for AD DirSyncRequest control.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncContainer extends AbstractContainer
+public class AdDirSyncRequestContainer extends AbstractContainer
 {
-    /** adDirSync */
-    private AdDirSync control;
+    /** adDirSync request */
+    private AdDirSyncRequest control;
 
     private LdapApiService codec;
 
 
     /**
-     * Creates a new AdDirSyncControl Container object.
+     * Creates a new AdDirSyncRequestControl Container object.
      *
      * @param codec The LDAP Service to use
      */
-    public AdDirSyncContainer( LdapApiService codec )
+    public AdDirSyncRequestContainer( LdapApiService codec )
     {
         super();
         this.codec = codec;
-        this.control = new AdDirSyncDecorator( codec );
-        setGrammar( AdDirSyncGrammar.getInstance() );
-        setTransition( AdDirSyncStatesEnum.START_STATE );
+        this.control = new AdDirSyncRequestDecorator( codec );
+        setGrammar( AdDirSyncRequestGrammar.getInstance() );
+        setTransition( AdDirSyncRequestStatesEnum.START_STATE );
     }
 
 
     /**
-     * Creates a new AdDirSyncControl object.
+     * Creates a new AdDirSyncRequestControl object.
      *
      * @param codec The LDAP Service to use
-     * @param control The AdDirSync control to decorate
+     * @param control The AdDirSyncRequest control to decorate
      */
-    public AdDirSyncContainer( LdapApiService codec, AdDirSync control )
+    public AdDirSyncRequestContainer( LdapApiService codec, AdDirSyncRequest control )
     {
         super();
         this.codec = codec;
         this.control = control;
-        setGrammar( AdDirSyncGrammar.getInstance() );
-        setTransition( AdDirSyncStatesEnum.START_STATE );
+        setGrammar( AdDirSyncRequestGrammar.getInstance() );
+        setTransition( AdDirSyncRequestStatesEnum.START_STATE );
     }
 
 
     /**
-     * @return the AdDirSyncControlCodec object
+     * @return the AdDirSyncRequestControlCodec object
      */
-    public AdDirSync getAdDirSyncControl()
+    public AdDirSyncRequest getAdDirSyncRequestControl()
     {
         return control;
     }
 
 
     /**
-     * Set a AdDirSyncControlCodec Object into the container. It will be completed
+     * Set a AdDirSyncRequestControlCodec Object into the container. It will be completed
      * by the ldapDecoder.
-     * 
-     * @param control the AdDirSyncControlCodec to set.
+     *
+     * @param control the AdDirSyncRequestControlCodec to set.
      */
-    public void setAdDirSyncControl( AdDirSync control )
+    public void setAdDirSyncRequestControl( AdDirSyncRequest control )
     {
         this.control = control;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestDecorator.java
similarity index 63%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestDecorator.java
index 7228182..bd7d4ca 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestDecorator.java
@@ -6,21 +6,20 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
 import java.nio.ByteBuffer;
-import java.util.Set;
 
 import org.apache.directory.api.asn1.Asn1Object;
 import org.apache.directory.api.asn1.DecoderException;
@@ -32,107 +31,86 @@ import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.ControlDecorator;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFlag;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequestImpl;
 import org.apache.directory.api.util.Strings;
 
 /**
- * A decorator around AdDirSync control. It will encode and decode this control.
- * 
+ * A decorator around AdDirSyncRequest control. It will encode and decode this control.
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements AdDirSync
+public class AdDirSyncRequestDecorator extends ControlDecorator<AdDirSyncRequest> implements AdDirSyncRequest
 {
     /** The global length for this control */
-    private int adDirSyncLength;
+    private int adDirSyncRequestLength;
 
     /** An instance of this decoder */
     private static final Asn1Decoder DECODER = new Asn1Decoder();
 
 
     /**
-     * Creates a new instance of AdDirSyncControlCodec.
-     * 
+     * Creates a new instance of AdDirSyncRequestControlCodec.
+     *
      * @param codec The LDAP Service to use
      */
-    public AdDirSyncDecorator( LdapApiService codec )
+    public AdDirSyncRequestDecorator( LdapApiService codec )
     {
-        super( codec, new AdDirSyncImpl() );
+        super( codec, new AdDirSyncRequestImpl() );
     }
 
 
     /**
-     * Creates a new instance of AdDirSyncDecorator.
+     * Creates a new instance of AdDirSyncRequestDecorator.
      *
      * @param codec The LDAP Service to use
      * @param control The control to be decorated
      */
-    public AdDirSyncDecorator( LdapApiService codec, AdDirSync control )
+    public AdDirSyncRequestDecorator( LdapApiService codec, AdDirSyncRequest control )
     {
         super( codec, control );
     }
-    
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Set<AdDirSyncFlag> getFlags()
-    {
-        return getDecorated().getFlags();
-    }
 
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void setFlags( Set<AdDirSyncFlag> flags )
-    {
-        getDecorated().setFlags( flags );
-    }
-    
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void addFlag( AdDirSyncFlag flag )
+    public int getParentsFirst()
     {
-        getDecorated().addFlag( flag );
+        return getDecorated().getParentsFirst();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void removeFlag( AdDirSyncFlag flag )
+    public void setParentsFirst( int parentsFirst )
     {
-        getDecorated().removeFlag( flag );
+        getDecorated().setParentsFirst( parentsFirst );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public int getMaxReturnLength()
+    public int getMaxAttributeCount()
     {
-        return getDecorated().getMaxReturnLength();
+        return getDecorated().getMaxAttributeCount();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void setMaxReturnLength( int maxReturnLength )
+    public void setMaxAttributeCount( int maxAttributeCount )
     {
-        getDecorated().setMaxReturnLength( maxReturnLength );
+        getDecorated().setMaxAttributeCount( maxAttributeCount );
     }
-    
+
 
     /**
      * {@inheritDoc}
@@ -165,12 +143,12 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
 
     /**
-     * Compute the AdDirSync length. We use the client side control.
+     * Compute the AdDirSyncRequest length. We use the client side control.
      * <pre>
      * 0x30 L1
      * |
-     * +--&gt; 0x02 0x0(1-4) nnn  (flags)
-     * +--&gt; 0x02 0x0(1-4) nnn  (maxReturnLength)
+     * +--&gt; 0x02 0x0(1-4) nnn  (parentFirst)
+     * +--&gt; 0x02 0x0(1-4) nnn  (maxAttributeCount)
      * +--&gt; 0x04 L2 xkcd!!!...     (cookie)
      * </pre>
      */
@@ -178,26 +156,26 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
     public int computeLength()
     {
         // the flags length
-        int flagsLength = BerValue.getNbBytes( AdDirSyncFlag.getBitmask( getFlags() ) );
-        adDirSyncLength = 1 + TLV.getNbBytes( flagsLength ) + flagsLength;
+        int parentFirstLength = BerValue.getNbBytes( getParentsFirst() );
+        adDirSyncRequestLength = 1 + TLV.getNbBytes( parentFirstLength ) + parentFirstLength;
 
-        // the maxReturnLength length
-        int maxReturnLengthLength = BerValue.getNbBytes( getMaxReturnLength() );
-        adDirSyncLength += 1 + TLV.getNbBytes( maxReturnLengthLength ) + maxReturnLengthLength;
+        // the maxAttributeCount length
+        int maxAttributeCountLength = BerValue.getNbBytes( getMaxAttributeCount() );
+        adDirSyncRequestLength += 1 + TLV.getNbBytes( maxAttributeCountLength ) + maxAttributeCountLength;
 
         // cookie's length
         byte[] cookie = getCookie();
-        
+
         if ( cookie == null )
         {
-            adDirSyncLength += 1 + 1;
+            adDirSyncRequestLength += 1 + 1;
         }
         else
         {
-            adDirSyncLength += 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
+            adDirSyncRequestLength += 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
         }
 
-        valueLength = 1 + TLV.getNbBytes( adDirSyncLength ) + adDirSyncLength;
+        valueLength = 1 + TLV.getNbBytes( adDirSyncRequestLength ) + adDirSyncRequestLength;
 
         // Call the super class to compute the global control length
         return valueLength;
@@ -205,7 +183,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
 
     /**
-     * Encode the AdDirSync control. We use the client side control.
+     * Encode the AdDirSyncRequest control. We use the client side control.
      *
      * @param buffer The encoded sink
      * @return A ByteBuffer that contains the encoded PDU
@@ -221,14 +199,14 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
         // Encode the SEQ
         buffer.put( UniversalTag.SEQUENCE.getValue() );
-        buffer.put( TLV.getBytes( adDirSyncLength ) );
+        buffer.put( TLV.getBytes( adDirSyncRequestLength ) );
+
+        // Encode the parentsFirst
+        BerValue.encode( buffer, getParentsFirst() );
 
-        // Encode the flags
-        BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
+        // Encode the MaxAttributeCount
+        BerValue.encode( buffer, getMaxAttributeCount() );
 
-        // Encode the MaxReturnLength
-        BerValue.encode( buffer, getMaxReturnLength() );
-        
         // Encode the cookie
         BerValue.encode( buffer, getCookie() );
 
@@ -251,14 +229,14 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
                 // Encode the SEQ
                 buffer.put( UniversalTag.SEQUENCE.getValue() );
-                buffer.put( TLV.getBytes( adDirSyncLength ) );
+                buffer.put( TLV.getBytes( adDirSyncRequestLength ) );
+
+                // Encode the parentFirst
+                BerValue.encode( buffer, getParentsFirst() );
 
-                // Encode the Flags flag
-                BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
+                // Encode the MaxAttributeCount
+                BerValue.encode( buffer, getMaxAttributeCount() );
 
-                // Encode the MaxReturnLength
-                BerValue.encode( buffer, getMaxReturnLength() );
-                
                 // Encode the cookie
                 BerValue.encode( buffer, getCookie() );
 
@@ -272,8 +250,8 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
         return value;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -281,8 +259,9 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
     public Asn1Object decode( byte[] controlBytes ) throws DecoderException
     {
         ByteBuffer bb = ByteBuffer.wrap( controlBytes );
-        AdDirSyncContainer container = new AdDirSyncContainer( getCodecService(), this );
+        AdDirSyncRequestContainer container = new AdDirSyncRequestContainer( getCodecService(), this );
         DECODER.decode( bb, container );
+
         return this;
     }
 }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestFactory.java
similarity index 61%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestFactory.java
index b1d022b..fb283d8 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestFactory.java
@@ -20,32 +20,33 @@
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
 
+import org.apache.directory.api.asn1.ber.tlv.BerValue;
 import org.apache.directory.api.asn1.util.Asn1Buffer;
 import org.apache.directory.api.ldap.codec.api.CodecControl;
 import org.apache.directory.api.ldap.codec.api.ControlFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncRequest;
 import org.apache.directory.api.ldap.model.message.Control;
 
 
 /**
- * A {@link ControlFactory} which creates {@link AdDirSync} controls.
+ * A {@link ControlFactory} which creates {@link AdDirSyncRequest} controls.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AdDirSyncFactory implements ControlFactory<AdDirSync>
+public class AdDirSyncRequestFactory implements ControlFactory<AdDirSyncRequest>
 {
     /** The codec for this factory */
     private LdapApiService codec;
 
 
     /**
-     * Creates a new instance of AdDirSyncFactory.
+     * Creates a new instance of AdDirSyncRequestFactory.
      *
      * @param codec The codec for this factory.
      */
-    public AdDirSyncFactory( LdapApiService codec )
+    public AdDirSyncRequestFactory( LdapApiService codec )
     {
         this.codec = codec;
     }
@@ -57,7 +58,7 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
     @Override
     public String getOid()
     {
-        return AdDirSync.OID;
+        return AdDirSyncRequest.OID;
     }
 
 
@@ -65,9 +66,9 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
      * {@inheritDoc}
      */
     @Override
-    public CodecControl<AdDirSync> newCodecControl()
+    public CodecControl<AdDirSyncRequest> newCodecControl()
     {
-        return new AdDirSyncDecorator( codec );
+        return new AdDirSyncRequestDecorator( codec );
     }
 
 
@@ -75,14 +76,31 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
      * {@inheritDoc}
      */
     @Override
-    public CodecControl<AdDirSync> newCodecControl( AdDirSync control )
+    public CodecControl<AdDirSyncRequest> newCodecControl( AdDirSyncRequest control )
     {
-        return new AdDirSyncDecorator( codec, control );
+        return new AdDirSyncRequestDecorator( codec, control );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void encodeValue( Asn1Buffer buffer, Control control )
     {
+        AdDirSyncRequest adDirSync = ( AdDirSyncRequest ) control;
+        int start = buffer.getPos();
+
+        // Encode the cookie
+        BerValue.encodeOctetString( buffer, adDirSync.getCookie() );
+
+        // Encode the MaxAttributeCount
+        BerValue.encodeInteger( buffer, adDirSync.getMaxAttributeCount() );
+
+        // Encode the ParentFirst value
+        BerValue.encodeInteger( buffer, adDirSync.getParentsFirst() );
+
+        // Encode the SEQ
+        BerValue.encodeSequence( buffer, start );
     }
 }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestGrammar.java
similarity index 51%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestGrammar.java
index 7de8401..714224e 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestGrammar.java
@@ -6,21 +6,19 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
-import java.util.Set;
-
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
 import org.apache.directory.api.asn1.ber.grammar.Grammar;
@@ -31,170 +29,164 @@ import org.apache.directory.api.asn1.ber.tlv.IntegerDecoder;
 import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
 import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFlag;
 import org.apache.directory.api.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * 
- * Implementation of AdDirSync Response Control. All the actions are declared in
+ *
+ * Implementation of AdDirSync Request Control. All the actions are declared in
  * this class. As it is a singleton, these declaration are only done once.
  *
  *  The decoded grammar is as follows :
- *  
+ *
  *  <pre>
  * realReplControlValue ::= SEQUENCE {
- *     flag                  integer
- *     maxReturnLength       integer
+ *     parentsFirst          integer
+ *     maxAttributeCount     integer
  *     cookie                OCTET STRING
  * }
- * </pre> 
- *  
+ * </pre>
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
+public final class AdDirSyncRequestGrammar extends AbstractGrammar<AdDirSyncRequestContainer>
 {
 
     /** the logger */
-    private static final Logger LOG = LoggerFactory.getLogger( AdDirSyncGrammar.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AdDirSyncRequestGrammar.class );
 
-    /** AdDirSyncControlGrammar singleton instance */
-    private static final AdDirSyncGrammar INSTANCE = new AdDirSyncGrammar();
+    /** AdDirSyncRequestControlGrammar singleton instance */
+    private static final AdDirSyncRequestGrammar INSTANCE = new AdDirSyncRequestGrammar();
 
 
     /**
-     * 
-     * Creates a new instance of AdDirSyncControlGrammar.
+     *
+     * Creates a new instance of AdDirSyncRequestControlGrammar.
      *
      */
     @SuppressWarnings("unchecked")
-    private AdDirSyncGrammar()
+    private AdDirSyncRequestGrammar()
     {
-        setName( AdDirSyncGrammar.class.getName() );
+        setName( AdDirSyncRequestGrammar.class.getName() );
 
-        super.transitions = new GrammarTransition[AdDirSyncStatesEnum.LAST_AD_DIR_SYNC_STATE.ordinal()][256];
+        super.transitions = new GrammarTransition[AdDirSyncRequestStatesEnum.LAST_AD_DIR_SYNC_REQUEST_STATE.ordinal()][256];
 
-        /** 
-         * Transition from initial state to AdDirSync sequence
+        /**
+         * Transition from initial state to AdDirSyncRequest sequence
          * AdDirSync ::= SEQUENCE {
          *     ...
-         *     
-         * Initialize the adDirSync object
+         *
+         * Initialize the adDirSyncRequest object
          */
-        super.transitions[AdDirSyncStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition<AdDirSyncContainer>(
-            AdDirSyncStatesEnum.START_STATE, AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
+        super.transitions[AdDirSyncRequestStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+            new GrammarTransition<AdDirSyncRequestContainer>(
+            AdDirSyncRequestStatesEnum.START_STATE, AdDirSyncRequestStatesEnum.AD_DIR_SYNC_REQUEST_SEQUENCE_STATE,
             UniversalTag.SEQUENCE.getValue(),
-            new GrammarAction<AdDirSyncContainer>( "Initialization" )
+            new GrammarAction<AdDirSyncRequestContainer>( "Initialization" )
             {
-                public void action( AdDirSyncContainer container ) throws DecoderException
+                @Override
+                public void action( AdDirSyncRequestContainer container ) throws DecoderException
                 {
                 }
             } );
 
-        
+
         /**
-         * transition from start to flag
+         * transition from start to parentsFirst
          * realReplControlValue ::= SEQUENCE {
-         *     flag            integer
+         *     parentsFirst          integer
          *    ....
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
+        super.transitions[AdDirSyncRequestStatesEnum.AD_DIR_SYNC_REQUEST_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
-                AdDirSyncStatesEnum.FLAG_STATE, UniversalTag.INTEGER.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl parentFirst" )
+            new GrammarTransition<AdDirSyncRequestContainer>( AdDirSyncRequestStatesEnum.AD_DIR_SYNC_REQUEST_SEQUENCE_STATE,
+                AdDirSyncRequestStatesEnum.PARENTS_FIRST_STATE, UniversalTag.INTEGER.getValue(),
+                new GrammarAction<AdDirSyncRequestContainer>( "Set AdDirSyncRequestControl parentsFirst" )
                 {
-                    public void action( AdDirSyncContainer container ) throws DecoderException
+                    @Override
+                    public void action( AdDirSyncRequestContainer container ) throws DecoderException
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
                         try
                         {
-                            int flagValue = IntegerDecoder.parse( value );
-                            
-                            Set<AdDirSyncFlag> flags = AdDirSyncFlag.getFlags( flagValue );
-                            
-                            if ( flags == null )
-                            {
-                                String msg = I18n.err( I18n.ERR_08104_AD_DIR_SYNC_FLAG_DECODING_FAILURE, flagValue );
-                                LOG.error( msg );
-                                throw new DecoderException( msg );
-                            }
-                            
+                            int parentsFirst = IntegerDecoder.parse( value );
+
                             if ( LOG.isDebugEnabled() )
                             {
-                                LOG.debug( I18n.msg( I18n.MSG_08101_FLAGS, flags.toString() ) );
+                                LOG.debug( I18n.msg( I18n.MSG_08108_PARENTS_FIRST, parentsFirst ) );
                             }
-                            
-                            container.getAdDirSyncControl().setFlags( flags );
+
+                            container.getAdDirSyncRequestControl().setParentsFirst( parentsFirst );
                         }
                         catch ( IntegerDecoderException ide )
                         {
-                            String msg = I18n.err( I18n.ERR_08105_AD_DIR_SYNC_FLAG_DECODING_ERROR, ide.getMessage() );
+                            String msg = I18n.err( I18n.ERR_08107_AD_DIR_SYNC_PARENTS_FIRST_DECODING_ERROR, ide.getMessage() );
                             LOG.error( msg, ide );
                             throw new DecoderException( msg, ide );
                         }
                     }
                 } );
 
-        
+
         /**
-         * transition from flag to maxReturnLength
+         * transition from flag to maxAttributeCount
          * realReplControlValue ::= SEQUENCE {
-         *     flag                    integer
-         *     maxReturnLength         integer
+         *     parentsFirst          integer
+         *     maxAttributeCount     integer
          *    ....
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.FLAG_STATE.ordinal()][UniversalTag.INTEGER
+        super.transitions[AdDirSyncRequestStatesEnum.PARENTS_FIRST_STATE.ordinal()][UniversalTag.INTEGER
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.FLAG_STATE,
-                AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE, UniversalTag.INTEGER.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl maxReturnLength" )
+            new GrammarTransition<AdDirSyncRequestContainer>( AdDirSyncRequestStatesEnum.PARENTS_FIRST_STATE,
+                AdDirSyncRequestStatesEnum.MAX_ATTRIBUTE_COUNT_STATE, UniversalTag.INTEGER.getValue(),
+                new GrammarAction<AdDirSyncRequestContainer>( "Set AdDirSyncRequestControl maxAttributeCount" )
                 {
-                    public void action( AdDirSyncContainer container ) throws DecoderException
+                    @Override
+                    public void action( AdDirSyncRequestContainer container ) throws DecoderException
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
                         try
                         {
-                            int maxReturnLength = IntegerDecoder.parse( value );
-                            
+                            int maxAttributeCount = IntegerDecoder.parse( value );
+
                             if ( LOG.isDebugEnabled() )
                             {
-                                LOG.debug( I18n.msg( I18n.MSG_08102_MAX_RETURN_LENGTH, maxReturnLength ) );
+                                LOG.debug( I18n.msg( I18n.MSG_08109_MAX_ATTRIBUTE_COUNT, maxAttributeCount ) );
                             }
-                            
-                            container.getAdDirSyncControl().setMaxReturnLength( maxReturnLength );
+
+                            container.getAdDirSyncRequestControl().setMaxAttributeCount( maxAttributeCount );
                         }
                         catch ( IntegerDecoderException ide )
                         {
-                            String msg = I18n.err( I18n.ERR_08106_AD_DIR_SYNC_MAX_RETURN_LENGTH_DECODING_ERROR, ide.getMessage() );
+                            String msg = I18n.err( I18n.ERR_08108_AD_DIR_SYNC_MAX_ATTRIBUTE_COUNT_DECODING_ERROR, ide.getMessage() );
                             LOG.error( msg, ide );
                             throw new DecoderException( msg, ide );
                         }
                     }
                 } );
-        
-        
+
+
         /**
-         * transition from maxReturnLength to cookie
+         * transition from maxAttributeCount to cookie
          *     ...
-         *     maxReturnLength         integer
+         *     maxAttributeCount         integer
          *     cookie                  OCTET STRING
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE.ordinal()][UniversalTag.OCTET_STRING
+        super.transitions[AdDirSyncRequestStatesEnum.MAX_ATTRIBUTE_COUNT_STATE.ordinal()][UniversalTag.OCTET_STRING
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE,
-                AdDirSyncStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl cookie" )
+            new GrammarTransition<AdDirSyncRequestContainer>( AdDirSyncRequestStatesEnum.MAX_ATTRIBUTE_COUNT_STATE,
+                AdDirSyncRequestStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
+                new GrammarAction<AdDirSyncRequestContainer>( "Set AdDirSyncRequestControl cookie" )
                 {
-                    public void action( AdDirSyncContainer container )
+                    @Override
+                    public void action( AdDirSyncRequestContainer container )
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
@@ -205,7 +197,7 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
                             LOG.debug( I18n.msg( I18n.MSG_08000_COOKIE, Strings.dumpBytes( cookie ) ) );
                         }
 
-                        container.getAdDirSyncControl().setCookie( cookie );
+                        container.getAdDirSyncRequestControl().setCookie( cookie );
 
                         container.setGrammarEndAllowed( true );
                     }
@@ -216,7 +208,7 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
     /**
      * @return the singleton instance of the AdDirSyncControlGrammar
      */
-    public static Grammar<AdDirSyncContainer> getInstance()
+    public static Grammar<AdDirSyncRequestContainer> getInstance()
     {
         return INSTANCE;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestStatesEnum.java
similarity index 75%
copy from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
copy to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestStatesEnum.java
index e5c4bf4..160e698 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncRequestStatesEnum.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
@@ -24,11 +24,11 @@ import org.apache.directory.api.asn1.ber.grammar.States;
 
 
 /**
- * ASN.1 grammar constants of AdDirSync Control.
- * 
+ * ASN.1 grammar constants of AdDirSyncRequest Control.
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum AdDirSyncStatesEnum implements States
+public enum AdDirSyncRequestStatesEnum implements States
 {
 
     /** The END_STATE */
@@ -38,40 +38,40 @@ public enum AdDirSyncStatesEnum implements States
     START_STATE,
 
     /** sequence start state */
-    AD_DIR_SYNC_SEQUENCE_STATE,
+    AD_DIR_SYNC_REQUEST_SEQUENCE_STATE,
 
-    /** flag state */
-    FLAG_STATE,
+    /** parentFirst state */
+    PARENTS_FIRST_STATE,
 
-    /** maxReturnLength value state */
-    MAX_RETURN_LENGTH_STATE,
+    /** maxAttributeCount value state */
+    MAX_ATTRIBUTE_COUNT_STATE,
 
     /** cookie value state */
     COOKIE_STATE,
 
     /** terminal state */
-    LAST_AD_DIR_SYNC_STATE;
+    LAST_AD_DIR_SYNC_REQUEST_STATE;
 
     /**
      * Get the grammar name
-     * 
+     *
      * @return The grammar name
      */
     public String getGrammarName()
     {
-        return "AD_DIR_SYNC_GRAMMAR";
+        return "AD_DIR_SYNC_REQUEST_GRAMMAR";
     }
 
 
     /**
      * Get the string representing the state
-     * 
+     *
      * @param state The state number
      * @return The String representing the state
      */
     public String getState( int state )
     {
-        return ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_GRAMMAR" : name();
+        return ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_REQUEST_GRAMMAR" : name();
     }
 
 
@@ -89,7 +89,7 @@ public enum AdDirSyncStatesEnum implements States
      * {@inheritDoc}
      */
     @Override
-    public AdDirSyncStatesEnum getStartState()
+    public AdDirSyncRequestStatesEnum getStartState()
     {
         return START_STATE;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseContainer.java
similarity index 61%
rename from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
rename to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseContainer.java
index 4263c17..4826553 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncContainer.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseContainer.java
@@ -6,86 +6,86 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
 
 import org.apache.directory.api.asn1.ber.AbstractContainer;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
 
 
 /**
- * 
- * ASN.1 container for AD DirSync control.
+ *
+ * ASN.1 container for AD DirSyncResponse control.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncContainer extends AbstractContainer
+public class AdDirSyncResponseContainer extends AbstractContainer
 {
     /** adDirSync */
-    private AdDirSync control;
+    private AdDirSyncResponse control;
 
     private LdapApiService codec;
 
 
     /**
-     * Creates a new AdDirSyncControl Container object.
+     * Creates a new AdDirSyncResponseControl Container object.
      *
      * @param codec The LDAP Service to use
      */
-    public AdDirSyncContainer( LdapApiService codec )
+    public AdDirSyncResponseContainer( LdapApiService codec )
     {
         super();
         this.codec = codec;
-        this.control = new AdDirSyncDecorator( codec );
-        setGrammar( AdDirSyncGrammar.getInstance() );
-        setTransition( AdDirSyncStatesEnum.START_STATE );
+        this.control = new AdDirSyncResponseDecorator( codec );
+        setGrammar( AdDirSyncResponseGrammar.getInstance() );
+        setTransition( AdDirSyncResponseStatesEnum.START_STATE );
     }
 
 
     /**
-     * Creates a new AdDirSyncControl object.
+     * Creates a new AdDirSyncResponseControl object.
      *
      * @param codec The LDAP Service to use
-     * @param control The AdDirSync control to decorate
+     * @param control The AdDirSyncResponse control to decorate
      */
-    public AdDirSyncContainer( LdapApiService codec, AdDirSync control )
+    public AdDirSyncResponseContainer( LdapApiService codec, AdDirSyncResponse control )
     {
         super();
         this.codec = codec;
         this.control = control;
-        setGrammar( AdDirSyncGrammar.getInstance() );
-        setTransition( AdDirSyncStatesEnum.START_STATE );
+        setGrammar( AdDirSyncResponseGrammar.getInstance() );
+        setTransition( AdDirSyncResponseStatesEnum.START_STATE );
     }
 
 
     /**
-     * @return the AdDirSyncControlCodec object
+     * @return the AdDirSyncResponseControlCodec object
      */
-    public AdDirSync getAdDirSyncControl()
+    public AdDirSyncResponse getAdDirSyncResponseControl()
     {
         return control;
     }
 
 
     /**
-     * Set a AdDirSyncControlCodec Object into the container. It will be completed
+     * Set a AdDirSyncResponseControlCodec Object into the container. It will be completed
      * by the ldapDecoder.
-     * 
-     * @param control the AdDirSyncControlCodec to set.
+     *
+     * @param control the AdDirSyncResponseControlCodec to set.
      */
-    public void setAdDirSyncControl( AdDirSync control )
+    public void setAdDirSyncControl( AdDirSyncResponse control )
     {
         this.control = control;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseDecorator.java
similarity index 87%
rename from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
rename to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseDecorator.java
index 7228182..4fbaaa2 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseDecorator.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
@@ -32,17 +32,17 @@ import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.ControlDecorator;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFlag;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFlag;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseImpl;
 import org.apache.directory.api.util.Strings;
 
 /**
  * A decorator around AdDirSync control. It will encode and decode this control.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements AdDirSync
+public class AdDirSyncResponseDecorator extends ControlDecorator<AdDirSyncResponse> implements AdDirSyncResponse
 {
     /** The global length for this control */
     private int adDirSyncLength;
@@ -53,12 +53,12 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
     /**
      * Creates a new instance of AdDirSyncControlCodec.
-     * 
+     *
      * @param codec The LDAP Service to use
      */
-    public AdDirSyncDecorator( LdapApiService codec )
+    public AdDirSyncResponseDecorator( LdapApiService codec )
     {
-        super( codec, new AdDirSyncImpl() );
+        super( codec, new AdDirSyncResponseImpl() );
     }
 
 
@@ -68,52 +68,52 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
      * @param codec The LDAP Service to use
      * @param control The control to be decorated
      */
-    public AdDirSyncDecorator( LdapApiService codec, AdDirSync control )
+    public AdDirSyncResponseDecorator( LdapApiService codec, AdDirSyncResponse control )
     {
         super( codec, control );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public Set<AdDirSyncFlag> getFlags()
+    public Set<AdDirSyncResponseFlag> getFlags()
     {
         return getDecorated().getFlags();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void setFlags( Set<AdDirSyncFlag> flags )
+    public void setFlags( Set<AdDirSyncResponseFlag> flags )
     {
         getDecorated().setFlags( flags );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void addFlag( AdDirSyncFlag flag )
+    public void addFlag( AdDirSyncResponseFlag flag )
     {
         getDecorated().addFlag( flag );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     @Override
-    public void removeFlag( AdDirSyncFlag flag )
+    public void removeFlag( AdDirSyncResponseFlag flag )
     {
         getDecorated().removeFlag( flag );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -123,7 +123,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
         return getDecorated().getMaxReturnLength();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -132,7 +132,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
     {
         getDecorated().setMaxReturnLength( maxReturnLength );
     }
-    
+
 
     /**
      * {@inheritDoc}
@@ -178,7 +178,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
     public int computeLength()
     {
         // the flags length
-        int flagsLength = BerValue.getNbBytes( AdDirSyncFlag.getBitmask( getFlags() ) );
+        int flagsLength = BerValue.getNbBytes( AdDirSyncResponseFlag.getBitmask( getFlags() ) );
         adDirSyncLength = 1 + TLV.getNbBytes( flagsLength ) + flagsLength;
 
         // the maxReturnLength length
@@ -187,7 +187,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
         // cookie's length
         byte[] cookie = getCookie();
-        
+
         if ( cookie == null )
         {
             adDirSyncLength += 1 + 1;
@@ -224,11 +224,11 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
         buffer.put( TLV.getBytes( adDirSyncLength ) );
 
         // Encode the flags
-        BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
+        BerValue.encode( buffer, AdDirSyncResponseFlag.getBitmask( getFlags() ) );
 
         // Encode the MaxReturnLength
         BerValue.encode( buffer, getMaxReturnLength() );
-        
+
         // Encode the cookie
         BerValue.encode( buffer, getCookie() );
 
@@ -254,11 +254,11 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
                 buffer.put( TLV.getBytes( adDirSyncLength ) );
 
                 // Encode the Flags flag
-                BerValue.encode( buffer, AdDirSyncFlag.getBitmask( getFlags() ) );
+                BerValue.encode( buffer, AdDirSyncResponseFlag.getBitmask( getFlags() ) );
 
                 // Encode the MaxReturnLength
                 BerValue.encode( buffer, getMaxReturnLength() );
-                
+
                 // Encode the cookie
                 BerValue.encode( buffer, getCookie() );
 
@@ -272,8 +272,8 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
 
         return value;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -281,7 +281,7 @@ public class AdDirSyncDecorator extends ControlDecorator<AdDirSync> implements A
     public Asn1Object decode( byte[] controlBytes ) throws DecoderException
     {
         ByteBuffer bb = ByteBuffer.wrap( controlBytes );
-        AdDirSyncContainer container = new AdDirSyncContainer( getCodecService(), this );
+        AdDirSyncResponseContainer container = new AdDirSyncResponseContainer( getCodecService(), this );
         DECODER.decode( bb, container );
         return this;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseFactory.java
similarity index 59%
rename from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
rename to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseFactory.java
index b1d022b..0363aa0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseFactory.java
@@ -20,32 +20,34 @@
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
 
+import org.apache.directory.api.asn1.ber.tlv.BerValue;
 import org.apache.directory.api.asn1.util.Asn1Buffer;
 import org.apache.directory.api.ldap.codec.api.CodecControl;
 import org.apache.directory.api.ldap.codec.api.ControlFactory;
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFlag;
 import org.apache.directory.api.ldap.model.message.Control;
 
 
 /**
- * A {@link ControlFactory} which creates {@link AdDirSync} controls.
+ * A {@link ControlFactory} which creates {@link AdDirSyncResponse} controls.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AdDirSyncFactory implements ControlFactory<AdDirSync>
+public class AdDirSyncResponseFactory implements ControlFactory<AdDirSyncResponse>
 {
     /** The codec for this factory */
     private LdapApiService codec;
 
 
     /**
-     * Creates a new instance of AdDirSyncFactory.
+     * Creates a new instance of AdDirSyncResponseFactory.
      *
      * @param codec The codec for this factory.
      */
-    public AdDirSyncFactory( LdapApiService codec )
+    public AdDirSyncResponseFactory( LdapApiService codec )
     {
         this.codec = codec;
     }
@@ -57,7 +59,7 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
     @Override
     public String getOid()
     {
-        return AdDirSync.OID;
+        return AdDirSyncResponse.OID;
     }
 
 
@@ -65,9 +67,9 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
      * {@inheritDoc}
      */
     @Override
-    public CodecControl<AdDirSync> newCodecControl()
+    public CodecControl<AdDirSyncResponse> newCodecControl()
     {
-        return new AdDirSyncDecorator( codec );
+        return new AdDirSyncResponseDecorator( codec );
     }
 
 
@@ -75,14 +77,31 @@ public class AdDirSyncFactory implements ControlFactory<AdDirSync>
      * {@inheritDoc}
      */
     @Override
-    public CodecControl<AdDirSync> newCodecControl( AdDirSync control )
+    public CodecControl<AdDirSyncResponse> newCodecControl( AdDirSyncResponse control )
     {
-        return new AdDirSyncDecorator( codec, control );
+        return new AdDirSyncResponseDecorator( codec, control );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void encodeValue( Asn1Buffer buffer, Control control )
     {
+        AdDirSyncResponse adDirSync = ( AdDirSyncResponse ) control;
+        int start = buffer.getPos();
+
+        // Encode the cookie
+        BerValue.encodeOctetString( buffer, adDirSync.getCookie() );
+
+        // Encode the MaxReturnLength/
+        BerValue.encodeInteger( buffer, adDirSync.getMaxReturnLength() );
+
+        // Encode the flags
+        BerValue.encodeInteger( buffer, AdDirSyncResponseFlag.getBitmask( adDirSync.getFlags() ) );
+
+        // Encode the SEQ
+        BerValue.encodeSequence( buffer, start );
     }
 }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseGrammar.java
similarity index 63%
rename from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
rename to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseGrammar.java
index 7de8401..e902e3d 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseGrammar.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
@@ -31,70 +31,71 @@ import org.apache.directory.api.asn1.ber.tlv.IntegerDecoder;
 import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
 import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFlag;
+import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFlag;
 import org.apache.directory.api.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * 
+ *
  * Implementation of AdDirSync Response Control. All the actions are declared in
  * this class. As it is a singleton, these declaration are only done once.
  *
  *  The decoded grammar is as follows :
- *  
+ *
  *  <pre>
  * realReplControlValue ::= SEQUENCE {
  *     flag                  integer
  *     maxReturnLength       integer
  *     cookie                OCTET STRING
  * }
- * </pre> 
- *  
+ * </pre>
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
+public final class AdDirSyncResponseGrammar extends AbstractGrammar<AdDirSyncResponseContainer>
 {
 
     /** the logger */
-    private static final Logger LOG = LoggerFactory.getLogger( AdDirSyncGrammar.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AdDirSyncResponseGrammar.class );
 
-    /** AdDirSyncControlGrammar singleton instance */
-    private static final AdDirSyncGrammar INSTANCE = new AdDirSyncGrammar();
+    /** AdDirSyncResponseControlGrammar singleton instance */
+    private static final AdDirSyncResponseGrammar INSTANCE = new AdDirSyncResponseGrammar();
 
 
     /**
-     * 
-     * Creates a new instance of AdDirSyncControlGrammar.
+     *
+     * Creates a new instance of AdDirSyncResponseControlGrammar.
      *
      */
     @SuppressWarnings("unchecked")
-    private AdDirSyncGrammar()
+    private AdDirSyncResponseGrammar()
     {
-        setName( AdDirSyncGrammar.class.getName() );
+        setName( AdDirSyncResponseGrammar.class.getName() );
 
-        super.transitions = new GrammarTransition[AdDirSyncStatesEnum.LAST_AD_DIR_SYNC_STATE.ordinal()][256];
+        super.transitions = new GrammarTransition[AdDirSyncResponseStatesEnum.LAST_AD_DIR_SYNC_RESPONSE_STATE.ordinal()][256];
 
-        /** 
-         * Transition from initial state to AdDirSync sequence
+        /**
+         * Transition from initial state to AdDirSyncResponse sequence
          * AdDirSync ::= SEQUENCE {
          *     ...
-         *     
-         * Initialize the adDirSync object
+         *
+         * Initialize the adDirSyncResponse object
          */
-        super.transitions[AdDirSyncStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = 
-            new GrammarTransition<AdDirSyncContainer>(
-            AdDirSyncStatesEnum.START_STATE, AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
+        super.transitions[AdDirSyncResponseStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+            new GrammarTransition<AdDirSyncResponseContainer>(
+            AdDirSyncResponseStatesEnum.START_STATE, AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
             UniversalTag.SEQUENCE.getValue(),
-            new GrammarAction<AdDirSyncContainer>( "Initialization" )
+            new GrammarAction<AdDirSyncResponseContainer>( "Initialization" )
             {
-                public void action( AdDirSyncContainer container ) throws DecoderException
+                @Override
+                public void action( AdDirSyncResponseContainer container ) throws DecoderException
                 {
                 }
             } );
 
-        
+
         /**
          * transition from start to flag
          * realReplControlValue ::= SEQUENCE {
@@ -102,35 +103,36 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
          *    ....
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
+        super.transitions[AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
-                AdDirSyncStatesEnum.FLAG_STATE, UniversalTag.INTEGER.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl parentFirst" )
+            new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
+                AdDirSyncResponseStatesEnum.FLAG_STATE, UniversalTag.INTEGER.getValue(),
+                new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl flag" )
                 {
-                    public void action( AdDirSyncContainer container ) throws DecoderException
+                    @Override
+                    public void action( AdDirSyncResponseContainer container ) throws DecoderException
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
                         try
                         {
                             int flagValue = IntegerDecoder.parse( value );
-                            
-                            Set<AdDirSyncFlag> flags = AdDirSyncFlag.getFlags( flagValue );
-                            
+
+                            Set<AdDirSyncResponseFlag> flags = AdDirSyncResponseFlag.getFlags( flagValue );
+
                             if ( flags == null )
                             {
                                 String msg = I18n.err( I18n.ERR_08104_AD_DIR_SYNC_FLAG_DECODING_FAILURE, flagValue );
                                 LOG.error( msg );
                                 throw new DecoderException( msg );
                             }
-                            
+
                             if ( LOG.isDebugEnabled() )
                             {
                                 LOG.debug( I18n.msg( I18n.MSG_08101_FLAGS, flags.toString() ) );
                             }
-                            
-                            container.getAdDirSyncControl().setFlags( flags );
+
+                            container.getAdDirSyncResponseControl().setFlags( flags );
                         }
                         catch ( IntegerDecoderException ide )
                         {
@@ -141,7 +143,7 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
                     }
                 } );
 
-        
+
         /**
          * transition from flag to maxReturnLength
          * realReplControlValue ::= SEQUENCE {
@@ -150,26 +152,27 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
          *    ....
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.FLAG_STATE.ordinal()][UniversalTag.INTEGER
+        super.transitions[AdDirSyncResponseStatesEnum.FLAG_STATE.ordinal()][UniversalTag.INTEGER
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.FLAG_STATE,
-                AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE, UniversalTag.INTEGER.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl maxReturnLength" )
+            new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.FLAG_STATE,
+                AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE, UniversalTag.INTEGER.getValue(),
+                new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl maxReturnLength" )
                 {
-                    public void action( AdDirSyncContainer container ) throws DecoderException
+                    @Override
+                    public void action( AdDirSyncResponseContainer container ) throws DecoderException
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
                         try
                         {
                             int maxReturnLength = IntegerDecoder.parse( value );
-                            
+
                             if ( LOG.isDebugEnabled() )
                             {
                                 LOG.debug( I18n.msg( I18n.MSG_08102_MAX_RETURN_LENGTH, maxReturnLength ) );
                             }
-                            
-                            container.getAdDirSyncControl().setMaxReturnLength( maxReturnLength );
+
+                            container.getAdDirSyncResponseControl().setMaxReturnLength( maxReturnLength );
                         }
                         catch ( IntegerDecoderException ide )
                         {
@@ -179,8 +182,8 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
                         }
                     }
                 } );
-        
-        
+
+
         /**
          * transition from maxReturnLength to cookie
          *     ...
@@ -188,13 +191,14 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
          *     cookie                  OCTET STRING
          * }
          */
-        super.transitions[AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE.ordinal()][UniversalTag.OCTET_STRING
+        super.transitions[AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE.ordinal()][UniversalTag.OCTET_STRING
             .getValue()] =
-            new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE,
-                AdDirSyncStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
-                new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl cookie" )
+            new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE,
+                AdDirSyncResponseStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
+                new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl cookie" )
                 {
-                    public void action( AdDirSyncContainer container )
+                    @Override
+                    public void action( AdDirSyncResponseContainer container )
                     {
                         BerValue value = container.getCurrentTLV().getValue();
 
@@ -205,7 +209,7 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
                             LOG.debug( I18n.msg( I18n.MSG_08000_COOKIE, Strings.dumpBytes( cookie ) ) );
                         }
 
-                        container.getAdDirSyncControl().setCookie( cookie );
+                        container.getAdDirSyncResponseControl().setCookie( cookie );
 
                         container.setGrammarEndAllowed( true );
                     }
@@ -216,7 +220,7 @@ public final class AdDirSyncGrammar extends AbstractGrammar<AdDirSyncContainer>
     /**
      * @return the singleton instance of the AdDirSyncControlGrammar
      */
-    public static Grammar<AdDirSyncContainer> getInstance()
+    public static Grammar<AdDirSyncResponseContainer> getInstance()
     {
         return INSTANCE;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseStatesEnum.java
similarity index 80%
rename from ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
rename to ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseStatesEnum.java
index e5c4bf4..8a4898a 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/AdDirSyncResponseStatesEnum.java
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.api.ldap.extras.controls.ad_impl;
 
@@ -24,11 +24,11 @@ import org.apache.directory.api.asn1.ber.grammar.States;
 
 
 /**
- * ASN.1 grammar constants of AdDirSync Control.
- * 
+ * ASN.1 grammar constants of AdDirSyncResponse Control.
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public enum AdDirSyncStatesEnum implements States
+public enum AdDirSyncResponseStatesEnum implements States
 {
 
     /** The END_STATE */
@@ -38,7 +38,7 @@ public enum AdDirSyncStatesEnum implements States
     START_STATE,
 
     /** sequence start state */
-    AD_DIR_SYNC_SEQUENCE_STATE,
+    AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
 
     /** flag state */
     FLAG_STATE,
@@ -50,28 +50,28 @@ public enum AdDirSyncStatesEnum implements States
     COOKIE_STATE,
 
     /** terminal state */
-    LAST_AD_DIR_SYNC_STATE;
+    LAST_AD_DIR_SYNC_RESPONSE_STATE;
 
     /**
      * Get the grammar name
-     * 
+     *
      * @return The grammar name
      */
     public String getGrammarName()
     {
-        return "AD_DIR_SYNC_GRAMMAR";
+        return "AD_DIR_SYNC_RESPONSE_GRAMMAR";
     }
 
 
     /**
      * Get the string representing the state
-     * 
+     *
      * @param state The state number
      * @return The String representing the state
      */
     public String getState( int state )
     {
-        return ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_GRAMMAR" : name();
+        return ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_RESPONSE_GRAMMAR" : name();
     }
 
 
@@ -89,7 +89,7 @@ public enum AdDirSyncStatesEnum implements States
      * {@inheritDoc}
      */
     @Override
-    public AdDirSyncStatesEnum getStartState()
+    public AdDirSyncResponseStatesEnum getStartState()
     {
         return START_STATE;
     }
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/controls/actions/AddControl.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/controls/actions/AddControl.java
index fbe584b..9711a2b 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/controls/actions/AddControl.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/endTransaction/controls/actions/AddControl.java
@@ -59,6 +59,7 @@ public class AddControl extends GrammarAction<ControlsContainer>
     /**
      * {@inheritDoc}
      */
+    @Override
     public void action( ControlsContainer container ) throws DecoderException
     {
         TLV tlv = container.getCurrentTLV();
@@ -87,11 +88,11 @@ public class AddControl extends GrammarAction<ControlsContainer>
             throw new DecoderException( msg );
         }
 
-        CodecControl<?> control = container.getLdapCodecService().newControl( oidValue );
+        CodecControl<?> control = container.getLdapCodecService().newResponseControl( oidValue );
 
         container.setCurrentControl( control );
         container.addControl( control );
-        
+
         // We can have an END transition
         container.setGrammarEndAllowed( true );
 
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
deleted file mode 100644
index 0a84420..0000000
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.directory.api.ldap.extras.controls.ad;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.util.EnumSet;
-
-import org.apache.directory.api.asn1.DecoderException;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.ldap.extras.AbstractCodecServiceTest;
-import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncDecorator;
-import org.apache.directory.api.util.Strings;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-
-/**
- * 
- * TestCase for AdDirSyncControlCodec .
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class AdDirSyncControlTest extends AbstractCodecServiceTest
-{
-    @Test
-    public void testAdDirSyncControl() throws Exception
-    {
-        ByteBuffer bb = ByteBuffer.allocate( 0x0F );
-
-        bb.put( new byte[]
-            {
-                0x30, 0x0D,
-                  0x02, 0x02, 0x08, 0x01,  // flag (LDAP_DIRSYNC_OBJECT_SECURITY, LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER)
-                  0x02, 0x01, 0x00,  // maxReturnLength (no limit)
-                  0x04, 0x04, 'x', 'k', 'c', 'd' // the cookie 
-        } );
-
-        bb.flip();
-
-        AdDirSync decorator = new AdDirSyncDecorator( codec );
-
-        AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
-
-        assertEquals( EnumSet.of( 
-            AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, 
-            AdDirSyncFlag.LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER ), 
-            adDirSync.getFlags() );
-        assertEquals( 0, adDirSync.getMaxReturnLength() );
-        assertEquals( "xkcd", Strings.utf8ToString( adDirSync.getCookie() ) );
-
-        // test encoding
-        try
-        {
-            ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
-                .allocate( ( ( AdDirSyncDecorator ) adDirSync ).computeLength() ) );
-            String expected = "0x30 0x0D 0x02 0x02 0x08 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
-            String decoded = Strings.dumpBytes( buffer.array() );
-            assertEquals( expected, decoded );
-        }
-        catch ( EncoderException e )
-        {
-            fail( e.getMessage() );
-        }
-    }
-
-
-    @Test
-    public void testAdDirSyncControlNoCookie() throws Exception
-    {
-        ByteBuffer bb = ByteBuffer.allocate( 0x0A );
-
-        bb.put( new byte[]
-            {
-                0x30, 0x08,
-                  0x02, 0x01, 0x01,  // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
-                  0x02, 0x01, 0x00,  // maxReturnLength (no limit)
-                  0x04, 0x00         // the cookie 
-        } );
-
-        bb.flip();
-
-        AdDirSync decorator = new AdDirSyncDecorator( codec );
-
-        AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
-
-        assertEquals( EnumSet.of( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY ), adDirSync.getFlags() );
-        assertEquals( 0, adDirSync.getMaxReturnLength() );
-        assertEquals( "", Strings.utf8ToString( adDirSync.getCookie() ) );
-
-        // test encoding
-        try
-        {
-            ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
-                .allocate( ( ( AdDirSyncDecorator ) adDirSync ).computeLength() ) );
-            String expected = "0x30 0x08 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x00 ";
-            String decoded = Strings.dumpBytes( buffer.array() );
-            assertEquals( expected, decoded );
-        }
-        catch ( EncoderException e )
-        {
-            fail( e.getMessage() );
-        }
-    }
-    
-    
-    @Test
-    public void testAdDirSyncControlAbsentCookie() throws Exception
-    {
-        ByteBuffer bb = ByteBuffer.allocate( 0x08 );
-
-        bb.put( new byte[]
-            {
-                0x30, 0x06,
-                  0x02, 0x01, 0x00,  // parentFirst (false)
-                  0x02, 0x01, 0x00   // maxReturnLength (no limit)
-        } );
-
-        bb.flip();
-
-        AdDirSync decorator = new AdDirSyncDecorator( codec );
-
-        try
-        {
-            ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
-            fail();
-        }
-        catch ( DecoderException de )
-        {
-            // expected
-        }
-    }
-    
-    
-    @Test
-    public void testAdDirSyncControlAbsentParentFirst() throws Exception
-    {
-        ByteBuffer bb = ByteBuffer.allocate( 0x07 );
-
-        bb.put( new byte[]
-            {
-                0x30, 0x05,
-                  0x02, 0x01, 0x00,  // maxReturnLength (no limit)
-                  0x04, 0x00         // cookie
-        } );
-
-        bb.flip();
-
-        AdDirSync decorator = new AdDirSyncDecorator( codec );
-
-        try
-        {
-            ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
-            fail();
-        }
-        catch ( DecoderException de )
-        {
-            // expected
-        }
-    }
-    
-    
-    @Test
-    public void testAdDirSyncControlEmpty() throws Exception
-    {
-        ByteBuffer bb = ByteBuffer.allocate( 0x02 );
-
-        bb.put( new byte[]
-            {
-                0x30, 0x00,
-        } );
-
-        bb.flip();
-
-        AdDirSync decorator = new AdDirSyncDecorator( codec );
-
-        try
-        {
-            ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
-            fail();
-        }
-        catch ( DecoderException de )
-        {
-            // expected
-        }
-    }
-}
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestControlTest.java
new file mode 100644
index 0000000..efd6df3
--- /dev/null
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncRequestControlTest.java
@@ -0,0 +1,187 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.api.ldap.extras.controls.ad;
+
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.api.asn1.DecoderException;
+import org.apache.directory.api.asn1.EncoderException;
+import org.apache.directory.api.asn1.util.Asn1Buffer;
+import org.apache.directory.api.ldap.extras.AbstractCodecServiceTest;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestDecorator;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncRequestFactory;
+import org.apache.directory.api.util.Strings;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+
+/**
+ *
+ * TestCase for AdDirSyncRequestControlCodec .
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class AdDirSyncRequestControlTest extends AbstractCodecServiceTest
+{
+    @Before
+    public void init()
+    {
+        codec.registerRequestControl( new AdDirSyncRequestFactory( codec ) );
+    }
+    @Test
+    public void testAdDirSyncRequestControl() throws DecoderException, EncoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x0F );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x0C,
+                  0x02, 0x01, 0x01,         // parentsFirst
+                  0x02, 0x01, 0x00,         // maxAttributeCount (no limit)
+                  0x04, 0x04,
+                    'x', 'k', 'c', 'd'      // the cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncRequest decorator = new AdDirSyncRequestDecorator( codec );
+
+        AdDirSyncRequest adDirSync = ( AdDirSyncRequest ) ( ( AdDirSyncRequestDecorator ) decorator ).decode( bb.array() );
+
+        assertEquals( 1, adDirSync.getParentsFirst() );
+        assertEquals( 0, adDirSync.getMaxAttributeCount() );
+        assertEquals( "xkcd", Strings.utf8ToString( adDirSync.getCookie() ) );
+
+        // test encoding
+        ByteBuffer buffer = ( ( AdDirSyncRequestDecorator ) adDirSync ).encode( ByteBuffer
+            .allocate( ( ( AdDirSyncRequestDecorator ) adDirSync ).computeLength() ) );
+        String expected = "0x30 0x0C 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
+        String decoded = Strings.dumpBytes( buffer.array() );
+        assertEquals( expected, decoded );
+    }
+
+
+    @Test
+    public void testAdDirSyncControlNoCookie() throws DecoderException, EncoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x0A );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x08,
+                  0x02, 0x01, 0x01,  // parentsFirst
+                  0x02, 0x01, 0x00,  // maxAttributeCount (no limit)
+                  0x04, 0x00         // the cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncRequest decorator = new AdDirSyncRequestDecorator( codec );
+
+        AdDirSyncRequest adDirSync = ( AdDirSyncRequest ) ( ( AdDirSyncRequestDecorator ) decorator ).decode( bb.array() );
+
+        assertEquals( 1, adDirSync.getParentsFirst() );
+        assertEquals( 0, adDirSync.getMaxAttributeCount() );
+        assertEquals( "", Strings.utf8ToString( adDirSync.getCookie() ) );
+
+        // test encoding
+        ByteBuffer buffer = ( ( AdDirSyncRequestDecorator ) adDirSync ).encode( ByteBuffer
+            .allocate( ( ( AdDirSyncRequestDecorator ) adDirSync ).computeLength() ) );
+        String expected = "0x30 0x08 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x00 ";
+        String decoded = Strings.dumpBytes( buffer.array() );
+        assertEquals( expected, decoded );
+
+        // Check the reverse encoding
+        Asn1Buffer asn1Buffer = new Asn1Buffer();
+
+        AdDirSyncRequestFactory factory = ( AdDirSyncRequestFactory ) codec.getRequestControlFactories().get( AdDirSyncRequest.OID );
+        factory.encodeValue( asn1Buffer, adDirSync );
+
+        assertArrayEquals( bb.array(),  asn1Buffer.getBytes().array() );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlAbsentCookie() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x08 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x06,
+                  0x02, 0x01, 0x00,  // parentsFirst
+                  0x02, 0x01, 0x00   // maxAttributeCount (no limit)
+            } );
+
+        bb.flip();
+
+        AdDirSyncRequest decorator = new AdDirSyncRequestDecorator( codec );
+
+        ( ( AdDirSyncRequestDecorator ) decorator ).decode( bb.array() );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlAbsentParentFirst() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x07 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x05,
+                  0x02, 0x01, 0x00,  // maxAttributeCount (no limit)
+                  0x04, 0x00         // cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncRequest decorator = new AdDirSyncRequestDecorator( codec );
+
+        ( ( AdDirSyncRequestDecorator ) decorator ).decode( bb.array() );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlEmpty() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x02 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x00,
+            } );
+
+        bb.flip();
+
+        AdDirSyncRequest decorator = new AdDirSyncRequestDecorator( codec );
+
+        ( ( AdDirSyncRequestDecorator ) decorator ).decode( bb.array() );
+    }
+}
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java
new file mode 100644
index 0000000..6d8192f
--- /dev/null
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java
@@ -0,0 +1,174 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.api.ldap.extras.controls.ad;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.nio.ByteBuffer;
+import java.util.EnumSet;
+
+import org.apache.directory.api.asn1.DecoderException;
+import org.apache.directory.api.asn1.EncoderException;
+import org.apache.directory.api.ldap.extras.AbstractCodecServiceTest;
+import org.apache.directory.api.ldap.extras.controls.ad_impl.AdDirSyncResponseDecorator;
+import org.apache.directory.api.util.Strings;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+
+/**
+ *
+ * TestCase for AdDirSyncControlCodec .
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class AdDirSyncResponseControlTest extends AbstractCodecServiceTest
+{
+    @Test
+    public void testAdDirSyncControl() throws DecoderException, EncoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x0F );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x0D,
+                  0x02, 0x02, 0x08, 0x01,   // flag (LDAP_DIRSYNC_OBJECT_SECURITY, LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER)
+                  0x02, 0x01, 0x00,         // maxReturnLength (no limit)
+                  0x04, 0x04,
+                    'x', 'k', 'c', 'd'      // the cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
+
+        AdDirSyncResponse adDirSync = ( AdDirSyncResponse ) ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
+
+        assertEquals( EnumSet.of(
+            AdDirSyncResponseFlag.LDAP_DIRSYNC_OBJECT_SECURITY,
+            AdDirSyncResponseFlag.LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER ),
+            adDirSync.getFlags() );
+        assertEquals( 0, adDirSync.getMaxReturnLength() );
+        assertEquals( "xkcd", Strings.utf8ToString( adDirSync.getCookie() ) );
+
+        // test encoding
+        ByteBuffer buffer = ( ( AdDirSyncResponseDecorator ) adDirSync ).encode( ByteBuffer
+            .allocate( ( ( AdDirSyncResponseDecorator ) adDirSync ).computeLength() ) );
+        String expected = "0x30 0x0D 0x02 0x02 0x08 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
+        String decoded = Strings.dumpBytes( buffer.array() );
+        assertEquals( expected, decoded );
+    }
+
+
+    @Test
+    public void testAdDirSyncControlNoCookie() throws DecoderException, EncoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x0A );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x08,
+                  0x02, 0x01, 0x01,  // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
+                  0x02, 0x01, 0x00,  // maxReturnLength (no limit)
+                  0x04, 0x00         // the cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
+
+        AdDirSyncResponse adDirSync = ( AdDirSyncResponse ) ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
+
+        assertEquals( EnumSet.of( AdDirSyncResponseFlag.LDAP_DIRSYNC_OBJECT_SECURITY ), adDirSync.getFlags() );
+        assertEquals( 0, adDirSync.getMaxReturnLength() );
+        assertEquals( "", Strings.utf8ToString( adDirSync.getCookie() ) );
+
+        // test encoding
+        ByteBuffer buffer = ( ( AdDirSyncResponseDecorator ) adDirSync ).encode( ByteBuffer
+            .allocate( ( ( AdDirSyncResponseDecorator ) adDirSync ).computeLength() ) );
+        String expected = "0x30 0x08 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x00 ";
+        String decoded = Strings.dumpBytes( buffer.array() );
+        assertEquals( expected, decoded );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlAbsentCookie() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x08 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x06,
+                  0x02, 0x01, 0x00,  // parentFirst (false)
+                  0x02, 0x01, 0x00   // maxReturnLength (no limit)
+            } );
+
+        bb.flip();
+
+        AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
+
+        ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlAbsentParentFirst() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x07 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x05,
+                  0x02, 0x01, 0x00,  // maxReturnLength (no limit)
+                  0x04, 0x00         // cookie
+            } );
+
+        bb.flip();
+
+        AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
+
+        ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
+    }
+
+
+    @Test( expected=DecoderException.class )
+    public void testAdDirSyncControlEmpty() throws DecoderException
+    {
+        ByteBuffer bb = ByteBuffer.allocate( 0x02 );
+
+        bb.put( new byte[]
+            {
+                0x30, 0x00,
+            } );
+
+        bb.flip();
+
+        AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
+
+        ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
+    }
+}