summaryrefslogtreecommitdiff
path: root/source3/lib/ldb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-21 15:18:05 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-21 15:18:05 +0100
commit47951fc5d0085e124666b7667715bba98076820e (patch)
tree67216ad0d594eb5a7238327c386ba34594142118 /source3/lib/ldb
parentd3199276eac8caa55c8334458d156fd4badae338 (diff)
downloadsamba-47951fc5d0085e124666b7667715bba98076820e.tar.gz
samba-47951fc5d0085e124666b7667715bba98076820e.tar.bz2
samba-47951fc5d0085e124666b7667715bba98076820e.zip
Reorder arguments to ldb_search() to match what is in Samba 4.
Diffstat (limited to 'source3/lib/ldb')
-rw-r--r--source3/lib/ldb/common/ldb.c22
-rw-r--r--source3/lib/ldb/common/ldb_modules.c2
-rw-r--r--source3/lib/ldb/examples/ldbreader.c4
-rw-r--r--source3/lib/ldb/include/ldb.h7
-rw-r--r--source3/lib/ldb/nssldb/ldb-grp.c23
-rw-r--r--source3/lib/ldb/nssldb/ldb-pwd.c17
-rw-r--r--source3/lib/ldb/tools/ad2oLschema.c17
-rw-r--r--source3/lib/ldb/tools/ldbdel.c2
-rw-r--r--source3/lib/ldb/tools/ldbedit.c2
-rw-r--r--source3/lib/ldb/tools/ldbtest.c4
10 files changed, 47 insertions, 53 deletions
diff --git a/source3/lib/ldb/common/ldb.c b/source3/lib/ldb/common/ldb.c
index c8aa6afdfc..495047f3a1 100644
--- a/source3/lib/ldb/common/ldb.c
+++ b/source3/lib/ldb/common/ldb.c
@@ -166,8 +166,8 @@ 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,
- "(objectClass=*)", attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, ldb_dn_new(tmp_ctx), LDB_SCOPE_BASE,
+ attrs, "(objectClass=*)");
if (ret == LDB_SUCCESS) {
if (res->count == 1) {
basedn = ldb_msg_find_attr_as_dn(ldb, res->msgs[0], "defaultNamingContext");
@@ -745,12 +745,12 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
note that ldb_search() will automatically replace a NULL 'base' value with the
defaultNamingContext from the rootDSE if available.
*/
-int ldb_search(struct ldb_context *ldb,
- const struct ldb_dn *base,
- enum ldb_scope scope,
- const char *expression,
- const char * const *attrs,
- struct ldb_result **_res)
+int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ struct ldb_result **_res,
+ const struct ldb_dn *base,
+ enum ldb_scope scope,
+ const char * const *attrs,
+ const char *expression)
{
struct ldb_request *req;
int ret;
@@ -758,12 +758,12 @@ int ldb_search(struct ldb_context *ldb,
*_res = NULL;
- res = talloc_zero(ldb, struct ldb_result);
+ res = talloc_zero(mem_ctx, struct ldb_result);
if (!res) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req(&req, ldb, ldb,
+ ret = ldb_build_search_req(&req, ldb, mem_ctx,
base?base:ldb_get_default_basedn(ldb),
scope,
expression,
@@ -819,7 +819,7 @@ int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(ldb, base, scope, expression, attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, base, scope, attrs, expression);
if (ret == LDB_SUCCESS) {
talloc_steal(mem_ctx, res);
diff --git a/source3/lib/ldb/common/ldb_modules.c b/source3/lib/ldb/common/ldb_modules.c
index fa7f685d97..8699cd8b95 100644
--- a/source3/lib/ldb/common/ldb_modules.c
+++ b/source3/lib/ldb/common/ldb_modules.c
@@ -340,7 +340,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
- ret = ldb_search(ldb, mods_dn, LDB_SCOPE_BASE, "", attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, mods_dn, LDB_SCOPE_BASE, attrs, "");
talloc_steal(mods_dn, res);
if (ret == LDB_SUCCESS && (res->count == 0 || res->msgs[0]->num_elements == 0)) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db\n");
diff --git a/source3/lib/ldb/examples/ldbreader.c b/source3/lib/ldb/examples/ldbreader.c
index baf0e9ab65..9ab21ee25f 100644
--- a/source3/lib/ldb/examples/ldbreader.c
+++ b/source3/lib/ldb/examples/ldbreader.c
@@ -88,8 +88,8 @@ int main(int argc, const char **argv)
quite fine grained results with the LDAP search syntax, however it is a bit
confusing to start with. See RFC2254.
*/
- if (LDB_SUCCESS != ldb_search(ldb, NULL, LDB_SCOPE_DEFAULT,
- expression, NULL, &resultMsg) ) {
+ if (LDB_SUCCESS != ldb_search(ldb, ldb, &resultMsg, NULL, LDB_SCOPE_DEFAULT,
+ NULL, expression) ) {
printf("Problem in search\n");
exit(-1);
}
diff --git a/source3/lib/ldb/include/ldb.h b/source3/lib/ldb/include/ldb.h
index 3891c1c6a3..d98536c480 100644
--- a/source3/lib/ldb/include/ldb.h
+++ b/source3/lib/ldb/include/ldb.h
@@ -987,11 +987,12 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
\note use talloc_free() to free the ldb_result returned
*/
-int ldb_search(struct ldb_context *ldb,
+int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ struct ldb_result **_res,
const struct ldb_dn *base,
enum ldb_scope scope,
- const char *expression,
- const char * const *attrs, struct ldb_result **_res);
+ const char * const *attrs,
+ const char *expression);
/*
* a useful search function where you can easily define the expression and
diff --git a/source3/lib/ldb/nssldb/ldb-grp.c b/source3/lib/ldb/nssldb/ldb-grp.c
index 71e27a9161..842a668d2f 100644
--- a/source3/lib/ldb/nssldb/ldb-grp.c
+++ b/source3/lib/ldb/nssldb/ldb-grp.c
@@ -59,12 +59,12 @@ NSS_STATUS _nss_ldb_setgrent(void)
_ldb_nss_ctx->gr_res = NULL;
}
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb,
+ &_ldb_nss_ctx->gr_res,
_ldb_nss_ctx->base,
- LDB_SCOPE_SUBTREE,
- _LDB_NSS_GRENT_FILTER,
+ LDB_SCOPE_SUBTREE,
_ldb_nss_gr_attrs,
- &_ldb_nss_ctx->gr_res);
+ _LDB_NSS_GRENT_FILTER);
if (ret != LDB_SUCCESS) {
return NSS_STATUS_UNAVAIL;
}
@@ -177,12 +177,11 @@ NSS_STATUS _nss_ldb_getgrnam_r(const char *name, struct group *result_buf, char
}
/* search the entry */
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb, &gr_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_gr_attrs,
- &gr_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -274,12 +273,11 @@ NSS_STATUS _nss_ldb_getgrgid_r(gid_t gid, struct group *result_buf, char *buffer
}
/* search the entry */
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb, &gr_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_gr_attrs,
- &gr_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -366,12 +364,11 @@ NSS_STATUS _nss_ldb_initgroups_dyn(const char *user, gid_t group, long int *star
}
/* search the entry */
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb, &uid_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
attrs,
- &uid_res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
diff --git a/source3/lib/ldb/nssldb/ldb-pwd.c b/source3/lib/ldb/nssldb/ldb-pwd.c
index 44b0ab21ee..0af7af9981 100644
--- a/source3/lib/ldb/nssldb/ldb-pwd.c
+++ b/source3/lib/ldb/nssldb/ldb-pwd.c
@@ -46,12 +46,12 @@ NSS_STATUS _nss_ldb_setpwent(void)
_ldb_nss_ctx->pw_res = NULL;
}
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb,
+ &_ldb_nss_ctx->pw_res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- _LDB_NSS_PWENT_FILTER,
_ldb_nss_pw_attrs,
- &_ldb_nss_ctx->pw_res);
+ _LDB_NSS_PWENT_FILTER);
if (ret != LDB_SUCCESS) {
return NSS_STATUS_UNAVAIL;
}
@@ -136,12 +136,12 @@ NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffe
}
/* search the entry */
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb, &res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_pw_attrs,
- &res);
+ filter
+ );
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
@@ -197,12 +197,11 @@ NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char
}
/* search the entry */
- ret = ldb_search(_ldb_nss_ctx->ldb,
+ ret = ldb_search(_ldb_nss_ctx->ldb, _ldb_nss_ctx->ldb, &res,
_ldb_nss_ctx->base,
LDB_SCOPE_SUBTREE,
- filter,
_ldb_nss_pw_attrs,
- &res);
+ filter);
if (ret != LDB_SUCCESS) {
/* this is a fatal error */
*errnop = errno = ENOENT;
diff --git a/source3/lib/ldb/tools/ad2oLschema.c b/source3/lib/ldb/tools/ad2oLschema.c
index fc51cb12d8..55406b29be 100644
--- a/source3/lib/ldb/tools/ad2oLschema.c
+++ b/source3/lib/ldb/tools/ad2oLschema.c
@@ -84,9 +84,8 @@ static int fetch_attrs_schema(struct ldb_context *ldb, struct ldb_dn *schemadn,
}
/* Downlaod schema */
- ret = ldb_search(ldb, schemadn, LDB_SCOPE_SUBTREE,
- "objectClass=attributeSchema",
- attrs, attrs_res);
+ ret = ldb_search(ldb, ldb, attrs_res, schemadn, LDB_SCOPE_SUBTREE,
+ attrs, "objectClass=attributeSchema");
if (ret != LDB_SUCCESS) {
printf("Search failed: %s\n", ldb_errstring(ldb));
return LDB_ERR_OPERATIONS_ERROR;
@@ -122,9 +121,8 @@ static int fetch_oc_recursive(struct ldb_context *ldb, struct ldb_dn *schemadn,
char *filter = talloc_asprintf(mem_ctx, "(&(&(objectClass=classSchema)(subClassOf=%s))(!(lDAPDisplayName=%s)))",
name, name);
- ret = ldb_search(ldb, schemadn, LDB_SCOPE_SUBTREE,
- filter,
- oc_attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, schemadn, LDB_SCOPE_SUBTREE,
+ oc_attrs, filter);
talloc_free(filter);
if (ret != LDB_SUCCESS) {
printf("Search failed: %s\n", ldb_errstring(ldb));
@@ -165,9 +163,8 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche
}
/* Downlaod 'top' */
- ret = ldb_search(ldb, schemadn, LDB_SCOPE_SUBTREE,
- "(&(objectClass=classSchema)(lDAPDisplayName=top))",
- oc_attrs, &top_res);
+ ret = ldb_search(ldb, ldb, &top_res, schemadn, LDB_SCOPE_SUBTREE,
+ oc_attrs, "(&(objectClass=classSchema)(lDAPDisplayName=top))");
if (ret != LDB_SUCCESS) {
printf("Search failed: %s\n", ldb_errstring(ldb));
return LDB_ERR_OPERATIONS_ERROR;
@@ -207,7 +204,7 @@ static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ct
}
/* Search for rootdse */
- ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_BASE, NULL, rootdse_attrs, &rootdse_res);
+ ldb_ret = ldb_search(ldb, ldb, &rootdse_res, basedn, LDB_SCOPE_BASE, rootdse_attrs, NULL);
if (ldb_ret != LDB_SUCCESS) {
printf("Search failed: %s\n", ldb_errstring(ldb));
return NULL;
diff --git a/source3/lib/ldb/tools/ldbdel.c b/source3/lib/ldb/tools/ldbdel.c
index a6d32f422f..cafe0bd352 100644
--- a/source3/lib/ldb/tools/ldbdel.c
+++ b/source3/lib/ldb/tools/ldbdel.c
@@ -41,7 +41,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const struct ldb_dn *dn
const char *attrs[] = { NULL };
struct ldb_result *res;
- ret = ldb_search(ldb, dn, LDB_SCOPE_SUBTREE, "distinguishedName=*", attrs, &res);
+ ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_SUBTREE, attrs, "distinguishedName=*");
if (ret != LDB_SUCCESS) return -1;
for (i = 0; i < res->count; i++) {
diff --git a/source3/lib/ldb/tools/ldbedit.c b/source3/lib/ldb/tools/ldbedit.c
index 0e1fd38e4c..dff7270e5d 100644
--- a/source3/lib/ldb/tools/ldbedit.c
+++ b/source3/lib/ldb/tools/ldbedit.c
@@ -306,7 +306,7 @@ int main(int argc, const char **argv)
}
}
- ret = ldb_search(ldb, basedn, options->scope, expression, attrs, &result);
+ ret = ldb_search(ldb, ldb, &result, basedn, options->scope, attrs, expression);
if (ret != LDB_SUCCESS) {
printf("search failed - %s\n", ldb_errstring(ldb));
exit(1);
diff --git a/source3/lib/ldb/tools/ldbtest.c b/source3/lib/ldb/tools/ldbtest.c
index b7fa874ad3..637eb5a7ff 100644
--- a/source3/lib/ldb/tools/ldbtest.c
+++ b/source3/lib/ldb/tools/ldbtest.c
@@ -225,7 +225,7 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nreco
int ret;
expr = talloc_asprintf(ldb, "(uid=TEST%d)", uid);
- ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res);
+ ret = ldb_search(ldb, ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, expr);
if (ret != LDB_SUCCESS || (uid < nrecords && res->count != 1)) {
printf("Failed to find %s - %s\n", expr, ldb_errstring(ldb));
@@ -345,7 +345,7 @@ static void start_test_index(struct ldb_context **ldb)
exit(1);
}
- ret = ldb_search(*ldb, basedn, LDB_SCOPE_SUBTREE, "uid=test", NULL, &res);
+ ret = ldb_search(*ldb, *ldb, basedn, LDB_SCOPE_SUBTREE, NULL, "uid=test");
if (ret != LDB_SUCCESS) {
printf("Search with (uid=test) filter failed!\n");
exit(1);