r12743: Remove the ugly way we had to make a second stage init and introduce
authorSimo Sorce <idra@samba.org>
Fri, 6 Jan 2006 16:12:45 +0000 (16:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:49:48 +0000 (13:49 -0500)
a second_stage_init private function for modules that need a second stage init.

Simo.
(This used to be commit 5e8b365fa2d93801a5de1d9ea76ce9d5546bd248)

21 files changed:
source4/dsdb/samdb/ldb_modules/extended_dn.c
source4/dsdb/samdb/ldb_modules/objectguid.c
source4/dsdb/samdb/ldb_modules/password_hash.c
source4/dsdb/samdb/ldb_modules/proxy.c
source4/dsdb/samdb/ldb_modules/rootdse.c
source4/dsdb/samdb/ldb_modules/samba3sam.c
source4/dsdb/samdb/ldb_modules/samldb.c
source4/lib/ldb/common/ldb.c
source4/lib/ldb/common/ldb_modules.c
source4/lib/ldb/include/ldb_private.h
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb/ldb_ldap/ldb_ldap.c
source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
source4/lib/ldb/ldb_tdb/ldb_tdb.c
source4/lib/ldb/modules/objectclass.c
source4/lib/ldb/modules/operational.c
source4/lib/ldb/modules/paged_results.c
source4/lib/ldb/modules/rdn_name.c
source4/lib/ldb/modules/schema.c
source4/lib/ldb/modules/skel.c
source4/lib/ldb/modules/sort.c

index 49af8604d5eb6cebd5618a3092657c66f76e7c33..839c190a8e5fac4eebfa7cf14584e53cfb208f94 100644 (file)
@@ -266,35 +266,34 @@ static int extended_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int extended_init_2(struct ldb_module *module)
+{
+       struct ldb_request request;
+       int ret;
+
+       request.operation = LDB_REQ_REGISTER;
+       request.op.reg.oid = LDB_CONTROL_EXTENDED_DN_OID;
+       request.controls = NULL;
+
+       ret = ldb_request(module->ldb, &request);
+       if (ret != LDB_SUCCESS) {
+               ldb_debug(module->ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n");
+               return LDB_ERR_OTHER;
+       }
+
+       return ldb_next_second_stage_init(module);
+}
+
 static const struct ldb_module_ops extended_dn_ops = {
        .name              = "extended_dn",
        .request           = extended_request,
+       .second_stage_init = extended_init_2
 };
 
-#ifdef HAVE_DLOPEN_DISABLED
-struct ldb_module *init_module(struct ldb_context *ldb, int stage, const char *options[])
-#else
-struct ldb_module *extended_dn_module_init(struct ldb_context *ldb, int stage, const char *options[])
-#endif
+struct ldb_module *extended_dn_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage == LDB_MODULES_INIT_STAGE_2) {
-               struct ldb_request request;
-               int ret;
-
-               request.operation = LDB_REQ_REGISTER;
-               request.op.reg.oid = LDB_CONTROL_EXTENDED_DN_OID;
-               request.controls = NULL;
-
-               ret = ldb_request(ldb, &request);
-               if (ret != LDB_SUCCESS) {
-                       ldb_debug(ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n");
-               }
-
-               return NULL;
-       }
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 935f92c55bd009d5cd46e6f53a129e07cf07b0f8..c9063af6ef950f5b2ed193be65d2990276d5a1b8 100644 (file)
@@ -128,12 +128,10 @@ static const struct ldb_module_ops objectguid_ops = {
 
 
 /* the init function */
-struct ldb_module *objectguid_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *objectguid_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 82e4639a23a1700ece9af388f6fd195b7267d6c7..2b979857d9952e9b614379f979cd54cb382c64af 100644 (file)
@@ -717,12 +717,10 @@ static const struct ldb_module_ops password_hash_ops = {
 
 
 /* the init function */
-struct ldb_module *password_hash_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *password_hash_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 540f4241b9917f7c6c595b1ba0e902d0d86a232b..2c66d2c1ec6079891efdfe9fc5f2d65a4ff5ba99 100644 (file)
@@ -333,12 +333,10 @@ static const struct ldb_module_ops proxy_ops = {
        .request        = proxy_request
 };
 
-struct ldb_module *proxy_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *proxy_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 8e0c231301736324d0ac966317b9055c56d6e099..68de8c884c20e958b4a8ddb5d901065d6c0564ef 100644 (file)
@@ -187,13 +187,11 @@ static const struct ldb_module_ops rootdse_ops = {
        .request        = rootdse_request
 };
 
-struct ldb_module *rootdse_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *rootdse_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
        struct private_data *data;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 035321a90b5cc7353fabddce4450acdc6427872b..429710c2c54fd721ae859c04eeea2f1562ea27e7 100644 (file)
@@ -878,9 +878,7 @@ const struct ldb_map_attribute samba3_attributes[] =
 };
 
        /* the init function */
-struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, const char *options[])
 {
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, "samba3sam");
 }
index 82c2d4d0cc03679d6ad3f097bd07988525e7df7b..7bf25994e28309174760af55cd7939ba42ebf743 100644 (file)
@@ -583,12 +583,10 @@ static const struct ldb_module_ops samldb_ops = {
 
 
 /* the init function */
-struct ldb_module *samldb_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *samldb_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 604f02a1f75e77a863ce0b5eb3e5b11badca17e6..78e6a74425336035ee450419b2a44333ffb10318 100644 (file)
@@ -120,6 +120,19 @@ static void ldb_reset_err_string(struct ldb_context *ldb)
        if (module == NULL) return -1; \
 } while (0)
 
+/*
+ second stage init all modules loaded
+*/
+int ldb_second_stage_init(struct ldb_context *ldb)
+{
+       struct ldb_module *module;
+
+       FIRST_OP(ldb, second_stage_init);
+
+       return module->ops->second_stage_init(module);
+}
+
+
 /*
   start a transaction
 */
index 26a397dccc77dd61507f08a394ea2140d5fb1ba5..715112a628d02d130ec2e82c3041700c04296851 100644 (file)
@@ -201,7 +201,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
                int m;
                for (m=0;well_known_modules[m].name;m++) {
                        if (strcmp(modules[i], well_known_modules[m].name) == 0) {
-                               current = well_known_modules[m].init(ldb, LDB_MODULES_INIT_STAGE_1, options);
+                               current = well_known_modules[m].init(ldb, options);
                                if (current == NULL) {
                                        ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
                                        return -1;
@@ -217,14 +217,9 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
        }
 
        /* second stage init */
-       for (i = 0; modules[i] != NULL; i++) {
-               int m;
-               for (m = 0; well_known_modules[m].name; m++) {
-                       if (strcmp(modules[i], well_known_modules[m].name) == 0) {
-                               well_known_modules[m].init(ldb, LDB_MODULES_INIT_STAGE_2, options);
-                               break;
-                       }
-               }
+       if (ldb_second_stage_init(ldb) != LDB_SUCCESS) {
+               ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: Second stage init failed!\n");
+               return -1;
        }
 
        talloc_free(modules);
@@ -239,7 +234,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
 #define FIND_OP(module, op) do { \
        module = module->next; \
        while (module && module->ops->op == NULL) module = module->next; \
-       if (module == NULL) return -1; \
+       if (module == NULL) return LDB_ERR_OTHER; \
 } while (0)
 
 
@@ -252,6 +247,12 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
        return module->ops->request(module, request);
 }
 
+int ldb_next_second_stage_init(struct ldb_module *module)
+{
+       FIND_OP(module, second_stage_init);
+       return module->ops->second_stage_init(module);
+}
+
 int ldb_next_start_trans(struct ldb_module *module)
 {
        FIND_OP(module, start_transaction);
index e8a4d1820a20b9109edae4598fd1630d935cfd28..4ef7c5a96dcecdadc5f6dec07b6d292e38efd56d 100644 (file)
@@ -60,6 +60,7 @@ struct ldb_module_ops {
        int (*start_transaction)(struct ldb_module *);
        int (*end_transaction)(struct ldb_module *);
        int (*del_transaction)(struct ldb_module *);
+       int (*second_stage_init)(struct ldb_module *);
 };
 
 
@@ -104,9 +105,7 @@ struct ldb_context {
 };
 
 /* the modules init function */
-#define LDB_MODULES_INIT_STAGE_1 1
-#define LDB_MODULES_INIT_STAGE_2 2
-typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage, const char **);
+typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **);
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
@@ -117,6 +116,9 @@ typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, int stage,
 */
 #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
 
+/* The following definitions come from lib/ldb/common/ldb.c */
+int ldb_second_stage_init(struct ldb_context *ldb);
+       
 /* The following definitions come from lib/ldb/common/ldb_modules.c  */
 
 int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
@@ -124,6 +126,7 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
 int ldb_next_start_trans(struct ldb_module *module);
 int ldb_next_end_trans(struct ldb_module *module);
 int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_second_stage_init(struct ldb_module *module);
 
 void ldb_set_errstring(struct ldb_module *module, char *err_string);
 
@@ -149,12 +152,12 @@ int lsqlite3_connect(struct ldb_context *ldb,
                     const char *url, 
                     unsigned int flags, 
                     const char *options[]);
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[]);
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[]);
+struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
+struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[]);
 
 
 int ldb_match_msg(struct ldb_context *ldb,
index ff00a61163a925801d9b99c1bbba7014ef584092..2837296b68b4a4044b0ea579a31382ab525c13d1 100644 (file)
@@ -441,12 +441,18 @@ static int ildb_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int ildb_init_2(struct ldb_module *module)
+{
+       return LDB_SUCCESS;
+}
+
 static const struct ldb_module_ops ildb_ops = {
        .name              = "ldap",
        .request           = ildb_request,
        .start_transaction = ildb_start_trans,
        .end_transaction   = ildb_end_trans,
-       .del_transaction   = ildb_del_trans
+       .del_transaction   = ildb_del_trans,
+       .second_stage_init = ildb_init_2
 };
 
 
index 8207b5f592fc639cdf4ab1d433c750370b1d54e3..dffd0e969cb0e96a8b7385e9ee45bf7b79b601b2 100644 (file)
@@ -514,12 +514,18 @@ static int lldb_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int lldb_init_2(struct ldb_module *module)
+{
+       return LDB_SUCCESS;
+}
+
 static const struct ldb_module_ops lldb_ops = {
        .name              = "ldap",
        .request           = lldb_request,
        .start_transaction = lldb_start_trans,
        .end_transaction   = lldb_end_trans,
-       .del_transaction   = lldb_del_trans
+       .del_transaction   = lldb_del_trans,
+       .second_stage_init = lldb_init_2
 };
 
 
index 464c8ce69fa5b1fcc58d02d8a31100ae734d8156..2e8b88a090098f249451c0ca3b0d7fd8ab0c8559 100644 (file)
@@ -1819,6 +1819,10 @@ static int lsqlite3_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int lsqlite3_init_2(struct ldb_module *module)
+{
+       return LDB_SUCCESS;
+}
 
 /*
  * Table of operations for the sqlite3 backend
@@ -1828,7 +1832,8 @@ static const struct ldb_module_ops lsqlite3_ops = {
        .request           = lsqlite3_request,
        .start_transaction = lsqlite3_start_trans,
        .end_transaction   = lsqlite3_end_trans,
-       .del_transaction   = lsqlite3_del_trans
+       .del_transaction   = lsqlite3_del_trans,
+       .second_stage_init = lsqlite3_init_2
 };
 
 /*
index 432c71333613fe527feb91b54bbad28076a61fa1..0a9a99ccead244da5b28b4836a60fb7e075ba659 100644 (file)
@@ -773,12 +773,18 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int ltdb_init_2(struct ldb_module *module)
+{
+       return LDB_SUCCESS;
+}
+
 static const struct ldb_module_ops ltdb_ops = {
        .name              = "tdb",
        .request           = ltdb_request,
        .start_transaction = ltdb_start_trans,
        .end_transaction   = ltdb_end_trans,
-       .del_transaction   = ltdb_del_trans
+       .del_transaction   = ltdb_del_trans,
+       .second_stage_init = ltdb_init_2
 };
 
 
index 7a037cc98aa0e4addae8adb15e3ce5523820200e..c38b3167e84d752727bc52b455e16878e66d58fa 100644 (file)
@@ -305,12 +305,10 @@ static const struct ldb_module_ops objectclass_ops = {
        .request           = objectclass_request,
 };
 
-struct ldb_module *objectclass_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *objectclass_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 09de0936a17c26a6bd90f15079bfe8485e527292..65d9f12e34a50ec4576e404739122507e6e1651f 100644 (file)
@@ -368,12 +368,10 @@ static const struct ldb_module_ops operational_ops = {
 
 
 /* the init function */
-struct ldb_module *operational_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-       
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 31b73d2ae4f6c8b909de56946734151f2f213ce2..8e9fc283485f73d6428a898c4e41c81d43de7d5e 100644 (file)
@@ -248,32 +248,35 @@ static int paged_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int paged_request_init_2(struct ldb_module *module)
+{
+       struct ldb_request request;
+       int ret;
+
+       request.operation = LDB_REQ_REGISTER;
+       request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID;
+       request.controls = NULL;
+
+       ret = ldb_request(module->ldb, &request);
+       if (ret != LDB_SUCCESS) {
+               ldb_debug(module->ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n");
+               return LDB_ERR_OTHER;
+       }
+
+       return ldb_next_second_stage_init(module);
+}
+
 static const struct ldb_module_ops paged_ops = {
        .name              = "paged_results",
        .request           = paged_request,
+       .second_stage_init = paged_request_init_2
 };
 
-struct ldb_module *paged_results_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *paged_results_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
        struct private_data *data;
 
-       if (stage == LDB_MODULES_INIT_STAGE_2) {
-               struct ldb_request request;
-               int ret;
-
-               request.operation = LDB_REQ_REGISTER;
-               request.op.reg.oid = LDB_CONTROL_PAGED_RESULTS_OID;
-               request.controls = NULL;
-
-               ret = ldb_request(ldb, &request);
-               if (ret != LDB_SUCCESS) {
-                       ldb_debug(ldb, LDB_DEBUG_ERROR, "paged_request: Unable to register control with rootdse!\n");
-               }
-
-               return NULL;
-       }
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index f6dbc387402ab7d40edd265f7c9a56a2bc3bd36b..f35cff916c25aeb0fa995d64ec84fa094f2d8516 100644 (file)
@@ -214,12 +214,10 @@ static const struct ldb_module_ops rdn_name_ops = {
 
 
 /* the init function */
-struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 778f52885cc7d3e8eb1d0114542fbfcf4a52eb59..9fb2efee30c7d96f093f26beac56ebf1c598aa6e 100644 (file)
@@ -484,12 +484,10 @@ static const struct ldb_module_ops schema_ops = {
        .request           = schema_request
 };
 
-struct ldb_module *schema_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage != LDB_MODULES_INIT_STAGE_1) return NULL;
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx) {
                return NULL;
index dacbd6960ede2f6d5c3ddcabcea8d42f0eba4a99..10f730b2f9715902f8866bafc74f2be501574206 100644 (file)
@@ -123,25 +123,27 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int skel_init_2(struct ldb_module *module)
+{
+       /* second stage init stuff */
+       /* see control modules as example */
+       return ldb_next_second_stage_init(module);
+}
+
 static const struct ldb_module_ops skel_ops = {
        .name              = "skel",
        .request           = skel_request,
        .start_transaction = skel_start_trans,
        .end_transaction   = skel_end_trans,
        .del_transaction   = skel_del_trans,
+       .second_stage_init = skel_init_2
 };
 
-struct ldb_module *skel_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *skel_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
        struct private_data *data;
 
-       if (stage == LDB_MODULES_INIT_STAGE_2) {
-               /* second stage init stuff */
-               /* see control modules as example */
-               return NULL;
-       }
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;
index 2757647710e9b1ef02df241738ed7286bd059425..88b967b2761fadcb7d53bc4815cec49237bdb6ba 100644 (file)
@@ -227,31 +227,34 @@ static int server_sort(struct ldb_module *module, struct ldb_request *req)
        }
 }
 
+static int server_sort_init_2(struct ldb_module *module)
+{
+       struct ldb_request request;
+       int ret;
+
+       request.operation = LDB_REQ_REGISTER;
+       request.op.reg.oid = LDB_CONTROL_SERVER_SORT_OID;
+       request.controls = NULL;
+
+       ret = ldb_request(module->ldb, &request);
+       if (ret != LDB_SUCCESS) {
+               ldb_debug(module->ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n");
+               return LDB_ERR_OTHER;
+       }
+
+       return ldb_next_second_stage_init(module);
+}
+
 static const struct ldb_module_ops server_sort_ops = {
        .name              = "server_sort",
        .request           = server_sort,
+       .second_stage_init = server_sort_init_2
 };
 
-struct ldb_module *server_sort_module_init(struct ldb_context *ldb, int stage, const char *options[])
+struct ldb_module *server_sort_module_init(struct ldb_context *ldb, const char *options[])
 {
        struct ldb_module *ctx;
 
-       if (stage == LDB_MODULES_INIT_STAGE_2) {
-               struct ldb_request request;
-               int ret;
-
-               request.operation = LDB_REQ_REGISTER;
-               request.op.reg.oid = LDB_CONTROL_SERVER_SORT_OID;
-               request.controls = NULL;
-
-               ret = ldb_request(ldb, &request);
-               if (ret != LDB_SUCCESS) {
-                       ldb_debug(ldb, LDB_DEBUG_ERROR, "server_sort: Unable to register control with rootdse!\n");
-               }
-
-               return NULL;
-       }
-
        ctx = talloc(ldb, struct ldb_module);
        if (!ctx)
                return NULL;