summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-11-22 00:59:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:22 -0500
commit4889eb9f7aae9349e426d0f6d2217adff67eaebd (patch)
tree7eb63c32bcbd19bf64d5c315f01785f30d3a789c /source4/lib/ldb/common/ldb.c
parentce0c2236b953dc977655dbceef40916825e843ae (diff)
downloadsamba-4889eb9f7aae9349e426d0f6d2217adff67eaebd.tar.gz
samba-4889eb9f7aae9349e426d0f6d2217adff67eaebd.tar.bz2
samba-4889eb9f7aae9349e426d0f6d2217adff67eaebd.zip
r19831: Big ldb_dn optimization and interfaces enhancement patch
This patch changes a lot of the code in ldb_dn.c, and also removes and add a number of manipulation functions around. The aim is to avoid validating a dn if not necessary as the validation code is necessarily slow. This is mainly to speed up internal operations where input is not user generated and so we can assume the DNs need no validation. The code is designed to keep the data as a string if possible. The code is not yet 100% perfect, but pass all the tests so far. A memleak is certainly present, I'll work on that next. Simo. (This used to be commit a580c871d3784602a9cce32d33419e63c8236e63)
Diffstat (limited to 'source4/lib/ldb/common/ldb.c')
-rw-r--r--source4/lib/ldb/common/ldb.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 9e0ee6ebca..c05f8313f1 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -153,7 +153,7 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op
pet hates about ldapsearch, which is that you have to get a long,
complex basedn right to make any use of it.
*/
-static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
+static struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
{
TALLOC_CTX *tmp_ctx;
int ret;
@@ -167,11 +167,11 @@ static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
}
tmp_ctx = talloc_new(ldb);
- ret = ldb_search(ldb, ldb_dn_new(tmp_ctx), LDB_SCOPE_BASE,
+ ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, NULL), LDB_SCOPE_BASE,
"(objectClass=*)", attrs, &res);
if (ret == LDB_SUCCESS) {
if (res->count == 1) {
- basedn = ldb_msg_find_attr_as_dn(ldb, res->msgs[0], "defaultNamingContext");
+ basedn = ldb_msg_find_attr_as_dn(ldb, ldb, res->msgs[0], "defaultNamingContext");
ldb_set_opaque(ldb, "default_baseDN", basedn);
}
talloc_free(res);
@@ -181,9 +181,9 @@ static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
return basedn;
}
-const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb)
+struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb)
{
- return (const struct ldb_dn *)ldb_get_opaque(ldb, "default_baseDN");
+ return (struct ldb_dn *)ldb_get_opaque(ldb, "default_baseDN");
}
/*
@@ -582,7 +582,7 @@ error:
int ldb_build_search_req(struct ldb_request **ret_req,
struct ldb_context *ldb,
void *mem_ctx,
- const struct ldb_dn *base,
+ struct ldb_dn *base,
enum ldb_scope scope,
const char *expression,
const char * const *attrs,
@@ -602,7 +602,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
req->operation = LDB_SEARCH;
if (base == NULL) {
- req->op.search.base = ldb_dn_new(req);
+ req->op.search.base = ldb_dn_new(req, ldb, NULL);
} else {
req->op.search.base = base;
}
@@ -685,7 +685,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req,
int ldb_build_del_req(struct ldb_request **ret_req,
struct ldb_context *ldb,
void *mem_ctx,
- const struct ldb_dn *dn,
+ struct ldb_dn *dn,
struct ldb_control **controls,
void *context,
ldb_request_callback_t callback)
@@ -714,8 +714,8 @@ int ldb_build_del_req(struct ldb_request **ret_req,
int ldb_build_rename_req(struct ldb_request **ret_req,
struct ldb_context *ldb,
void *mem_ctx,
- const struct ldb_dn *olddn,
- const struct ldb_dn *newdn,
+ struct ldb_dn *olddn,
+ struct ldb_dn *newdn,
struct ldb_control **controls,
void *context,
ldb_request_callback_t callback)
@@ -747,7 +747,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
defaultNamingContext from the rootDSE if available.
*/
int ldb_search(struct ldb_context *ldb,
- const struct ldb_dn *base,
+ struct ldb_dn *base,
enum ldb_scope scope,
const char *expression,
const char * const *attrs,
@@ -861,7 +861,7 @@ int ldb_modify(struct ldb_context *ldb,
/*
delete a record from the database
*/
-int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
+int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn)
{
struct ldb_request *req;
int ret;
@@ -886,7 +886,7 @@ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
/*
rename a record in the database
*/
-int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
+int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *newdn)
{
struct ldb_request *req;
int ret;