diff --git a/source/modules/vfs_recycle.c b/source/modules/vfs_recycle.c
index da17167..f752eeb 100644
--- a/source/modules/vfs_recycle.c
+++ b/source/modules/vfs_recycle.c
@@ -34,6 +34,7 @@ static int vfs_recycle_debug_level = DBGC_VFS;
 static int recycle_connect(vfs_handle_struct *handle, const char *service, const char *user);
 static void recycle_disconnect(vfs_handle_struct *handle);
 static int recycle_unlink(vfs_handle_struct *handle, const char *name);
+static int recycle_rmdir(vfs_handle_struct *handle, const char *path);
 
 static vfs_op_tuple recycle_ops[] = {
 
@@ -43,6 +44,7 @@ static vfs_op_tuple recycle_ops[] = {
 
 	/* File operations */
 	{SMB_VFS_OP(recycle_unlink),	SMB_VFS_OP_UNLINK,	SMB_VFS_LAYER_TRANSPARENT},
+	{SMB_VFS_OP(recycle_rmdir),	SMB_VFS_OP_RMDIR,	SMB_VFS_LAYER_TRANSPARENT},
 
 	{SMB_VFS_OP(NULL),		SMB_VFS_OP_NOOP,	SMB_VFS_LAYER_NOOP}
 };
@@ -585,6 +587,63 @@ done:
 	return rc;
 }
 
+/**
+ * Check if file should be recycled
+ **/
+static int recycle_rmdir(vfs_handle_struct *handle, const char *path)
+{
+	connection_struct *conn = handle->conn;
+	char *repository = NULL;
+	char *temp_name = NULL;
+	bool exist;
+	int rc = -1;
+
+	repository = talloc_sub_advanced(NULL, lp_servicename(SNUM(conn)),
+					conn->user,
+					conn->connectpath, conn->gid,
+					get_current_username(),
+					current_user_info.domain,
+					recycle_repository(handle));
+	ALLOC_CHECK(repository, done);
+	trim_char(repository, '\0', '/');
+
+	if(!repository || *(repository) == '\0') {
+		DEBUG(3, ("recycle: repository path not set, purging %s...\n", path));
+		rc = SMB_VFS_NEXT_RMDIR(handle, path);
+		goto done;
+	}
+
+	/* we don't recycle the recycle bin... */
+	if (strncmp(path, repository, strlen(repository)) == 0) {
+		DEBUG(3, ("recycle: Directory is within recycling bin, rmdir ...\n"));
+		rc = SMB_VFS_NEXT_RMDIR(handle, path);
+		goto done;
+	}
+
+	if (recycle_keep_dir_tree(handle) == True) {
+		asprintf(&temp_name, "%s/%s", repository, path);
+	}
+	ALLOC_CHECK(temp_name, done);
+
+	exist = recycle_directory_exist(handle, temp_name);
+	if (exist) {
+		DEBUG(10, ("recycle: Directory already exists\n"));
+	} else {
+		DEBUG(10, ("recycle: Creating directory %s\n", temp_name));
+		if (recycle_create_dir(handle, temp_name) == False) {
+			DEBUG(3, ("recycle: Could not create directory, purging %s...\n", path));
+			rc = SMB_VFS_NEXT_RMDIR(handle, path);
+			goto done;
+		}
+	}
+	rc = SMB_VFS_NEXT_RMDIR(handle, path);
+
+done:
+	SAFE_FREE(temp_name);
+	TALLOC_FREE(repository);
+	return rc;
+}
+
 NTSTATUS vfs_recycle_init(void);
 NTSTATUS vfs_recycle_init(void)
 {
