Now that we pass down the event context, start removing calls to
[metze/samba/wip.git] / source / lib / ldb / ldb_ildap / ldb_ildap.c
index 0c0ee629bfc98e94f3f24a08703491a7e40b0155..d1677032f0b98bb75e7a9d5e36850b8c4a4d5473 100644 (file)
@@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        struct ildb_private *ildb;
        NTSTATUS status;
        struct cli_credentials *creds;
+       struct event_context *event_ctx;
 
        module = talloc(ldb, struct ldb_module);
        if (!module) {
@@ -756,7 +757,11 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
        }
        module->private_data    = ildb;
        ildb->module            = module;
-       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "EventContext"));
+
+       event_ctx = ldb_get_event_context(ldb);
+
+       ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
+                                         event_ctx);
        if (!ildb->ldap) {
                ldb_oom(ldb);
                goto failed;
@@ -793,7 +798,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
                                goto failed;
                        }
                } else {
-                       status = ldap_bind_sasl(ildb->ldap, creds, global_loadparm);
+                       status = ldap_bind_sasl(ildb->ldap, creds, ldb_get_opaque(ldb, "loadparm"));
                        if (!NT_STATUS_IS_OK(status)) {
                                ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n",
                                          ldap_errstr(ildb->ldap, module, status));
@@ -810,9 +815,18 @@ failed:
        return -1;
 }
 
-int ldb_ildap_init(void)
-{
-       return ldb_register_backend("ldap", ildb_connect) + 
-                  ldb_register_backend("ldapi", ildb_connect) + 
-                  ldb_register_backend("ldaps", ildb_connect);
-}
+_PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = {
+       .name = "ldap",
+       .connect_fn = ildb_connect
+};
+
+_PUBLIC_ const struct ldb_backend_ops ldb_ldapi_backend_ops = {
+       .name = "ldapi",
+       .connect_fn = ildb_connect
+};
+
+_PUBLIC_ const struct ldb_backend_ops ldb_ldaps_backend_ops = {
+       .name = "ldaps",
+       .connect_fn = ildb_connect
+};
+