svn commit: samba r13743 - in
branches/SAMBA_4_0/source/lib/ldb/ldb_ildap: .
idra at samba.org
idra at samba.org
Tue Feb 28 04:37:48 GMT 2006
Author: idra
Date: 2006-02-28 04:37:47 +0000 (Tue, 28 Feb 2006)
New Revision: 13743
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13743
Log:
Generic fixes and improvements
Modified:
branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c 2006-02-28 04:36:29 UTC (rev 13742)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c 2006-02-28 04:37:47 UTC (rev 13743)
@@ -24,10 +24,22 @@
*/
/*
- This is a ldb backend for the internal ldap client library in
- Samba4. By using this backend we are independent of a system ldap
- library
-*/
+ * Name: ldb_ildap
+ *
+ * Component: ldb ildap backend
+ *
+ * Description: This is a ldb backend for the internal ldap
+ * client library in Samba4. By using this backend we are
+ * independent of a system ldap library
+ *
+ * Author: Andrew Tridgell
+ *
+ * Modifications:
+ *
+ * - description: make the module use asyncronous calls
+ * date: Feb 2006
+ * author: Simo Sorce
+ */
#include "includes.h"
@@ -141,7 +153,7 @@
{
struct ldb_async_handle *handle = talloc_get_type(req->async.private_data, struct ldb_async_handle);
struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
- struct ildb_private *ildb = ac->module->private_data;
+ struct ildb_private *ildb = talloc_get_type(ac->module->private_data, struct ildb_private);
NTSTATUS status;
int i;
@@ -166,6 +178,10 @@
}
status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
handle->status = ildb_map_error(ildb, status);
+ if (ac->callback && handle->status == LDB_SUCCESS) {
+ /* FIXME: build a corresponding ares to pass on */
+ handle->status = ac->callback(ac->module->ldb, ac->context, NULL);
+ }
handle->state = LDB_ASYNC_DONE;
break;
@@ -176,6 +192,10 @@
}
status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
handle->status = ildb_map_error(ildb, status);
+ if (ac->callback && handle->status == LDB_SUCCESS) {
+ /* FIXME: build a corresponding ares to pass on */
+ handle->status = ac->callback(ac->module->ldb, ac->context, NULL);
+ }
handle->state = LDB_ASYNC_DONE;
break;
@@ -186,6 +206,10 @@
}
status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
handle->status = ildb_map_error(ildb, status);
+ if (ac->callback && handle->status == LDB_SUCCESS) {
+ /* FIXME: build a corresponding ares to pass on */
+ handle->status = ac->callback(ac->module->ldb, ac->context, NULL);
+ }
handle->state = LDB_ASYNC_DONE;
break;
@@ -196,6 +220,10 @@
}
status = ldap_check_response(req->conn, &req->replies[0]->r.GeneralResult);
handle->status = ildb_map_error(ildb, status);
+ if (ac->callback && handle->status == LDB_SUCCESS) {
+ /* FIXME: build a corresponding ares to pass on */
+ handle->status = ac->callback(ac->module->ldb, ac->context, NULL);
+ }
handle->state = LDB_ASYNC_DONE;
break;
@@ -302,7 +330,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ildb_async_context *ildb_ac;
struct ldb_async_handle *h;
struct ldap_request *req;
@@ -362,7 +390,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
int n;
@@ -422,12 +450,6 @@
return ildb_request_send(module, msg, context, callback, timeout, handle);
}
-struct ildb_sync_context {
- struct ldb_result *res;
- int status;
- int done;
-};
-
static int ildb_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
{
struct ldb_result *res;
@@ -476,12 +498,10 @@
res->refs[n + 1] = NULL;
}
- if (ares->type == LDB_REPLY_DONE) {
- if (ares->controls) {
- res->controls = talloc_steal(res, ares->controls);
- if (! res->controls) {
- goto error;
- }
+ if (ares->controls) {
+ res->controls = talloc_steal(res, ares->controls);
+ if (! res->controls) {
+ goto error;
}
}
@@ -504,7 +524,7 @@
struct ldb_control **control_req,
struct ldb_result **res)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_async_handle *handle;
int ret;
@@ -531,7 +551,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
@@ -578,7 +598,7 @@
static int ildb_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_async_handle *handle;
int ret;
@@ -600,7 +620,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
@@ -647,7 +667,7 @@
static int ildb_modify(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_async_handle *handle;
int ret;
@@ -669,7 +689,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
*handle = NULL;
@@ -697,7 +717,7 @@
static int ildb_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_async_handle *handle;
int ret;
@@ -720,7 +740,7 @@
int timeout,
struct ldb_async_handle **handle)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
*handle = NULL;
@@ -766,7 +786,7 @@
static int ildb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
- struct ildb_private *ildb = module->private_data;
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldb_async_handle *handle;
int ret;
@@ -878,37 +898,7 @@
}
}
-/*
- fetch the rootDSE for later use
-*/
-static int ildb_init_2(struct ldb_module *module)
-{
- struct ildb_private *ildb = module->private_data;
- struct ldb_result *res = NULL;
- struct ldb_dn *empty_dn = ldb_dn_new(ildb);
- int ret;
- ret = ildb_search_bytree(module, empty_dn, LDB_SCOPE_BASE,
- ldb_parse_tree(empty_dn, "dn=dc=rootDSE"),
- NULL, NULL, &res);
- if (ret == LDB_SUCCESS && res->count == 1) {
- ildb->rootDSE = talloc_steal(ildb, res->msgs[0]);
- }
- if (ret == LDB_SUCCESS) talloc_free(res);
- talloc_free(empty_dn);
- 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,
- .second_stage_init = ildb_init_2
-};
-
-
static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
{
struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
@@ -917,6 +907,8 @@
return LDB_ERR_OPERATIONS_ERROR;
}
+ handle->state = LDB_ASYNC_INIT;
+
switch(type) {
case LDB_WAIT_NONE:
if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
@@ -924,7 +916,6 @@
}
break;
case LDB_WAIT_ONCE:
- handle->state = LDB_ASYNC_INIT;
while (handle->status == LDB_SUCCESS && handle->state == LDB_ASYNC_INIT) {
if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
return LDB_ERR_OTHER;
@@ -946,6 +937,36 @@
}
/*
+ fetch the rootDSE for later use
+*/
+static int ildb_init_2(struct ldb_module *module)
+{
+ struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ldb_result *res = NULL;
+ struct ldb_dn *empty_dn = ldb_dn_new(ildb);
+ int ret;
+ ret = ildb_search_bytree(module, empty_dn, LDB_SCOPE_BASE,
+ ldb_parse_tree(empty_dn, "dn=dc=rootDSE"),
+ NULL, NULL, &res);
+ if (ret == LDB_SUCCESS && res->count == 1) {
+ ildb->rootDSE = talloc_steal(ildb, res->msgs[0]);
+ }
+ if (ret == LDB_SUCCESS) talloc_free(res);
+ talloc_free(empty_dn);
+
+ 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,
+ .second_stage_init = ildb_init_2
+};
+
+/*
connect to the database
*/
int ildb_connect(struct ldb_context *ldb, const char *url,
More information about the samba-cvs
mailing list