diff options
author | Simo Sorce <idra@samba.org> | 2004-11-15 11:40:27 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:51 -0500 |
commit | 679e95db033fd11d17c1f1ac5e44f6cc4df2220e (patch) | |
tree | 2a6138f9c6c66025ac0e68965dc73f32846f0d1b /source4/lib/ldb/ldb_ldap/ldb_ldap.c | |
parent | 5b397619ccd3a2189c053209387093b60ff53094 (diff) | |
download | samba-679e95db033fd11d17c1f1ac5e44f6cc4df2220e.tar.gz samba-679e95db033fd11d17c1f1ac5e44f6cc4df2220e.tar.bz2 samba-679e95db033fd11d17c1f1ac5e44f6cc4df2220e.zip |
r3754: merge in ldb modules support from the tmp branch ldbPlugins
(This used to be commit 71323f424b4561af1fdddd2358629049be3dad8c)
Diffstat (limited to 'source4/lib/ldb/ldb_ldap/ldb_ldap.c')
-rw-r--r-- | source4/lib/ldb/ldb_ldap/ldb_ldap.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 9ac51b26fe..96aee088a7 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -68,10 +68,11 @@ static const char *lldb_option_find(const struct lldb_private *lldb, const char /* close/free the connection */ -static int lldb_close(struct ldb_context *ldb) +static int lldb_close(struct ldb_module *module) { int i, ret = 0; - struct lldb_private *lldb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct lldb_private *lldb = module->private_data; if (ldap_unbind(lldb->ldap) != LDAP_SUCCESS) { ret = -1; @@ -94,9 +95,10 @@ static int lldb_close(struct ldb_context *ldb) /* rename a record */ -static int lldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn) +static int lldb_rename(struct ldb_module *module, const char *olddn, const char *newdn) { - struct lldb_private *lldb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct lldb_private *lldb = module->private_data; int ret = 0; char *newrdn, *p; const char *parentdn = ""; @@ -129,9 +131,9 @@ static int lldb_rename(struct ldb_context *ldb, const char *olddn, const char *n /* delete a record */ -static int lldb_delete(struct ldb_context *ldb, const char *dn) +static int lldb_delete(struct ldb_module *module, const char *dn) { - struct lldb_private *lldb = ldb->private_data; + struct lldb_private *lldb = module->private_data; int ret = 0; /* ignore ltdb specials */ @@ -171,8 +173,9 @@ static int lldb_msg_free(struct ldb_context *ldb, struct ldb_message *msg) /* free a search result */ -static int lldb_search_free(struct ldb_context *ldb, struct ldb_message **res) +static int lldb_search_free(struct ldb_module *module, struct ldb_message **res) { + struct ldb_context *ldb = module->ldb; int i; for (i=0;res[i];i++) { if (lldb_msg_free(ldb, res[i]) != 0) { @@ -243,11 +246,12 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, /* search for matching records */ -static int lldb_search(struct ldb_context *ldb, const char *base, +static int lldb_search(struct ldb_module *module, const char *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res) { - struct lldb_private *lldb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct lldb_private *lldb = module->private_data; int count, msg_count; LDAPMessage *ldapres, *msg; @@ -335,7 +339,7 @@ static int lldb_search(struct ldb_context *ldb, const char *base, return msg_count; failed: - if (*res) lldb_search_free(ldb, *res); + if (*res) lldb_search_free(module, *res); return -1; } @@ -434,9 +438,10 @@ failed: /* add a record */ -static int lldb_add(struct ldb_context *ldb, const struct ldb_message *msg) +static int lldb_add(struct ldb_module *module, const struct ldb_message *msg) { - struct lldb_private *lldb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct lldb_private *lldb = module->private_data; LDAPMod **mods; int ret = 0; @@ -461,9 +466,10 @@ static int lldb_add(struct ldb_context *ldb, const struct ldb_message *msg) /* modify a record */ -static int lldb_modify(struct ldb_context *ldb, const struct ldb_message *msg) +static int lldb_modify(struct ldb_module *module, const struct ldb_message *msg) { - struct lldb_private *lldb = ldb->private_data; + struct ldb_context *ldb = module->ldb; + struct lldb_private *lldb = module->private_data; LDAPMod **mods; int ret = 0; @@ -488,14 +494,15 @@ static int lldb_modify(struct ldb_context *ldb, const struct ldb_message *msg) /* return extended error information */ -static const char *lldb_errstring(struct ldb_context *ldb) +static const char *lldb_errstring(struct ldb_module *module) { - struct lldb_private *lldb = ldb->private_data; + struct lldb_private *lldb = module->private_data; return ldap_err2string(lldb->last_rc); } -static const struct ldb_backend_ops lldb_ops = { +static const struct ldb_module_ops lldb_ops = { + "ldap", lldb_close, lldb_search, lldb_search_free, @@ -544,8 +551,16 @@ struct ldb_context *lldb_connect(const char *url, goto failed; } - ldb->ops = &lldb_ops; - ldb->private_data = lldb; + ldb->modules = ldb_malloc_p(ldb, struct ldb_module); + if (!ldb->modules) { + ldb_free(ldb, ldb); + errno = ENOMEM; + goto failed; + } + ldb->modules->ldb = ldb; + ldb->modules->prev = ldb->modules->next = NULL; + ldb->modules->private_data = lldb; + ldb->modules->ops = &lldb_ops; if (options) { /* take a copy of the options array, so we don't have to rely |