TreeDelete control (1.2.840.113556.1.4.805)
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index 10efcb9..8349d74 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -67,6 +67,8 @@
 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
 import org.apache.directory.api.ldap.codec.api.MessageEncoderException;
 import org.apache.directory.api.ldap.codec.api.SchemaBinaryAttributeDetector;
+import org.apache.directory.api.ldap.extras.controls.ad.TreeDelete;
+import org.apache.directory.api.ldap.extras.controls.ad.TreeDeleteImpl;
 import org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl;
 import org.apache.directory.api.ldap.model.constants.LdapConstants;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -3642,13 +3644,11 @@
      */
     public void deleteTree( Dn dn ) throws LdapException
     {
-        String treeDeleteOid = "1.2.840.113556.1.4.805";
-
-        if ( isControlSupported( treeDeleteOid ) )
+        if ( isControlSupported( TreeDelete.OID ) )
         {
             DeleteRequest deleteRequest = new DeleteRequestImpl();
             deleteRequest.setName( dn );
-            deleteRequest.addControl( new OpaqueControl( treeDeleteOid ) );
+            deleteRequest.addControl( new TreeDeleteImpl() );
             DeleteResponse deleteResponse = delete( deleteRequest );
 
             processResponse( deleteResponse );
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDelete.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDelete.java
new file mode 100644
index 0000000..744497f
--- /dev/null
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDelete.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.directory.api.ldap.model.message.Control;
+
+
+/**
+ * The Active Directory Tree Delete control. It is used to delete object and its sub-objects.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface TreeDelete extends Control
+{
+    /** Tree Delete control OID */
+    String OID = "1.2.840.113556.1.4.805";
+}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDeleteImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDeleteImpl.java
new file mode 100644
index 0000000..72ed2be
--- /dev/null
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/TreeDeleteImpl.java
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.directory.api.ldap.model.message.controls.AbstractControl;
+
+
+/**
+ * The Active Directory Tree Delete control implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class TreeDeleteImpl extends AbstractControl implements TreeDelete
+{
+    /**
+     * Default constructor
+     */
+    public TreeDeleteImpl()
+    {
+        super( OID );
+    }
+
+
+    /**
+     * Sets criticality when creating.
+     *
+     * @param isCritical true if critical, false otherwise.
+     */
+    public TreeDeleteImpl( boolean isCritical )
+    {
+        super( OID );
+        setCritical( isCritical );
+    }
+
+    /**
+     * @see Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        return "TreeDelete control";
+    }
+}
\ No newline at end of file
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasCodecFactoryUtil.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasCodecFactoryUtil.java
index b1d6f3a..7d96951 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasCodecFactoryUtil.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasCodecFactoryUtil.java
@@ -31,10 +31,12 @@
 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.AdShowDeleted;
+import org.apache.directory.api.ldap.extras.controls.ad.TreeDelete;
 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.ad_impl.TreeDeleteFactory;
 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.passwordExpired.PasswordExpiredResponse;
@@ -133,6 +135,10 @@
         ControlFactory<AdShowDeleted> adShowDeletedFactory = new AdShowDeletedFactory( apiService );
         requestControlFactories.put( adShowDeletedFactory.getOid(), adShowDeletedFactory );
 
+        // TreeDelete
+        ControlFactory<TreeDelete> treeDeleteFactory = new TreeDeleteFactory( apiService );
+        requestControlFactories.put( treeDeleteFactory.getOid(), treeDeleteFactory );
+
         if ( LOG.isInfoEnabled() )
         {
             LOG.info( I18n.msg( I18n.MSG_06000_REGISTERED_CONTROL_FACTORY, adShowDeletedFactory.getOid() ) );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/TreeDeleteFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/TreeDeleteFactory.java
new file mode 100644
index 0000000..66b8148
--- /dev/null
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad_impl/TreeDeleteFactory.java
@@ -0,0 +1,57 @@
+/*
+ *   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_impl;
+
+
+import org.apache.directory.api.ldap.codec.api.AbstractControlFactory;
+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.TreeDelete;
+import org.apache.directory.api.ldap.extras.controls.ad.TreeDeleteImpl;
+
+
+/**
+ * A codec {@link ControlFactory} implementation for {@link TreeDelete} controls.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TreeDeleteFactory extends AbstractControlFactory<TreeDelete>
+{
+    /**
+     * Creates a new instance of TreeDeleteFactory.
+     *
+     * @param codec The LDAP codec
+     */
+    public TreeDeleteFactory( LdapApiService codec )
+    {
+        super( codec, TreeDelete.OID );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public TreeDelete newControl()
+    {
+        return new TreeDeleteImpl();
+    }
+}