diff options
-rw-r--r-- | source3/groupdb/mapping_ldb.c | 52 | ||||
-rw-r--r-- | source3/lib/ldb/common/ldb.c | 24 | ||||
-rw-r--r-- | source3/lib/ldb/common/ldb_modules.c | 2 | ||||
-rw-r--r-- | source3/lib/ldb/examples/ldbreader.c | 5 | ||||
-rw-r--r-- | source3/lib/ldb/include/ldb.h | 13 | ||||
-rw-r--r-- | source3/lib/ldb/modules/ldb_map.c | 2 | ||||
-rw-r--r-- | source3/lib/ldb/nssldb/ldb-grp.c | 53 | ||||
-rw-r--r-- | source3/lib/ldb/nssldb/ldb-pwd.c | 38 | ||||
-rw-r--r-- | source3/lib/ldb/tools/ad2oLschema.c | 21 | ||||
-rw-r--r-- | source3/lib/ldb/tools/ldbdel.c | 2 | ||||
-rw-r--r-- | source3/lib/ldb/tools/ldbedit.c | 2 | ||||
-rw-r--r-- | source3/lib/ldb/tools/ldbtest.c | 10 |
12 files changed, 62 insertions, 162 deletions
diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c index db3215552f..af99b86c45 100644 --- a/source3/groupdb/mapping_ldb.c +++ b/source3/groupdb/mapping_ldb.c @@ -221,7 +221,7 @@ static bool get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map) dn = mapping_dn(ldb, &sid); if (dn == NULL) goto failed; - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_BASE, NULL, NULL); talloc_steal(dn, res); if (ret != LDB_SUCCESS || res->count != 1) { goto failed; @@ -243,24 +243,16 @@ failed: static bool get_group_map_from_gid(gid_t gid, GROUP_MAP *map) { int ret; - char *expr; struct ldb_result *res=NULL; - expr = talloc_asprintf(ldb, "(&(gidNumber=%u)(objectClass=groupMap))", - (unsigned)gid); - if (expr == NULL) goto failed; - - ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res); - talloc_steal(expr, res); + ret = ldb_search(ldb, ldb, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(gidNumber=%u)(objectClass=groupMap))", (unsigned)gid); if (ret != LDB_SUCCESS || res->count != 1) goto failed; if (!msg_to_group_map(res->msgs[0], map)) goto failed; - talloc_free(expr); return True; failed: - talloc_free(expr); return False; } @@ -270,23 +262,16 @@ failed: static bool get_group_map_from_ntname(const char *name, GROUP_MAP *map) { int ret; - char *expr; struct ldb_result *res=NULL; - expr = talloc_asprintf(ldb, "(&(ntName=%s)(objectClass=groupMap))", name); - if (expr == NULL) goto failed; - - ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res); - talloc_steal(expr, res); + ret = ldb_search(ldb, ldb, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(ntName=%s)(objectClass=groupMap))", name); if (ret != LDB_SUCCESS || res->count != 1) goto failed; if (!msg_to_group_map(res->msgs[0], map)) goto failed; - talloc_free(expr); return True; failed: - talloc_free(expr); return False; } @@ -317,7 +302,6 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_ size_t *p_num_entries, bool unix_only) { int i, ret; - char *expr; fstring name; struct ldb_result *res = NULL; struct ldb_dn *basedn=NULL; @@ -326,14 +310,6 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_ tmp_ctx = talloc_new(ldb); if (tmp_ctx == NULL) goto failed; - if (sid_name_use == SID_NAME_UNKNOWN) { - expr = talloc_asprintf(tmp_ctx, "(&(objectClass=groupMap))"); - } else { - expr = talloc_asprintf(tmp_ctx, "(&(sidNameUse=%u)(objectClass=groupMap))", - sid_name_use); - } - if (expr == NULL) goto failed; - /* we do a subtree search on the domain */ if (domsid != NULL) { sid_to_fstring(name, domsid); @@ -341,7 +317,15 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_ if (basedn == NULL) goto failed; } - ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res); + if (sid_name_use == SID_NAME_UNKNOWN) { + ret = ldb_search(ldb, ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, + "(&(objectClass=groupMap))"); + } else { + ret = ldb_search(ldb, ldb, &res, basedn, LDB_SCOPE_SUBTREE, NULL, + "(&(sidNameUse=%u)(objectClass=groupMap))", + sid_name_use); + } + talloc_steal(tmp_ctx, res); if (ret != LDB_SUCCESS) goto failed; @@ -380,7 +364,6 @@ static NTSTATUS one_alias_membership(const DOM_SID *member, NULL }; DOM_SID alias; - char *expr; int ret, i; struct ldb_result *res=NULL; fstring string_sid; @@ -390,12 +373,7 @@ static NTSTATUS one_alias_membership(const DOM_SID *member, return NT_STATUS_INVALID_PARAMETER; } - expr = talloc_asprintf(ldb, "(&(member=%s)(objectClass=groupMap))", - string_sid); - if (expr == NULL) goto failed; - - ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, attrs, &res); - talloc_steal(expr, res); + ret = ldb_search(ldb, ldb, &res, NULL, LDB_SCOPE_SUBTREE, attrs, "(&(member=%s)(objectClass=groupMap))", string_sid); if (ret != LDB_SUCCESS) { goto failed; } @@ -414,11 +392,9 @@ static NTSTATUS one_alias_membership(const DOM_SID *member, } } - talloc_free(expr); return NT_STATUS_OK; failed: - talloc_free(expr); return status; } @@ -515,7 +491,7 @@ static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num) return NT_STATUS_NO_MEMORY; } - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_BASE, attrs, NULL); talloc_steal(dn, res); if (ret == LDB_SUCCESS && res->count == 0) { talloc_free(dn); diff --git a/source3/lib/ldb/common/ldb.c b/source3/lib/ldb/common/ldb.c index c8aa6afdfc..6e28528dbf 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) +static 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, @@ -799,7 +799,7 @@ done: takes a memory context where results are allocated */ -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, +int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, const char *exp_fmt, ...) { @@ -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..35ea03b20e 100644 --- a/source3/lib/ldb/examples/ldbreader.c +++ b/source3/lib/ldb/examples/ldbreader.c @@ -56,7 +56,6 @@ static int vprintf_fn(void *private_data, const char *fmt, ...) int main(int argc, const char **argv) { struct ldb_context *ldb; - const char *expression = "(dn=*)"; struct ldb_result *resultMsg; int i; @@ -88,8 +87,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, "(dn=*)") ) { 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..113652a1a7 100644 --- a/source3/lib/ldb/include/ldb.h +++ b/source3/lib/ldb/include/ldb.h @@ -987,18 +987,7 @@ 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, - const struct ldb_dn *base, - enum ldb_scope scope, - const char *expression, - const char * const *attrs, struct ldb_result **_res); - -/* - * a useful search function where you can easily define the expression and - * that takes a memory context where results are allocated -*/ - -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, +int ldb_search(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, const char *exp_fmt, ...); diff --git a/source3/lib/ldb/modules/ldb_map.c b/source3/lib/ldb/modules/ldb_map.c index 54e1758c1e..bda6cdcda5 100644 --- a/source3/lib/ldb/modules/ldb_map.c +++ b/source3/lib/ldb/modules/ldb_map.c @@ -1199,7 +1199,7 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res); + ret = ldb_search(module->ldb, module->ldb, &res, dn, LDB_SCOPE_BASE, attrs, NULL); talloc_free(dn); if (ret != LDB_SUCCESS) { return ret; diff --git a/source3/lib/ldb/nssldb/ldb-grp.c b/source3/lib/ldb/nssldb/ldb-grp.c index 71e27a9161..82598e1e95 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; } @@ -151,7 +151,6 @@ NSS_STATUS _nss_ldb_getgrent_r(struct group *result_buf, char *buffer, size_t bu NSS_STATUS _nss_ldb_getgrnam_r(const char *name, struct group *result_buf, char *buffer, size_t buflen, int *errnop) { int ret; - char *filter; TALLOC_CTX *ctx; struct ldb_result *gr_res; struct ldb_result *mem_res; @@ -167,22 +166,12 @@ NSS_STATUS _nss_ldb_getgrnam_r(const char *name, struct group *result_buf, char return NSS_STATUS_UNAVAIL; } - /* build the filter for this uid */ - filter = talloc_asprintf(ctx, _LDB_NSS_GRNAM_FILTER, name); - if (filter == NULL) { - /* this is a fatal error */ - *errnop = errno = ENOMEM; - ret = NSS_STATUS_UNAVAIL; - goto done; - } - /* 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); + _LDB_NSS_GRNAM_FILTER, name); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -243,7 +232,6 @@ done: NSS_STATUS _nss_ldb_getgrgid_r(gid_t gid, struct group *result_buf, char *buffer, size_t buflen, int *errnop) { int ret; - char *filter; TALLOC_CTX *ctx; struct ldb_result *gr_res; struct ldb_result *mem_res; @@ -264,22 +252,12 @@ NSS_STATUS _nss_ldb_getgrgid_r(gid_t gid, struct group *result_buf, char *buffer return NSS_STATUS_UNAVAIL; } - /* build the filter for this uid */ - filter = talloc_asprintf(ctx, _LDB_NSS_GRGID_FILTER, gid); - if (filter == NULL) { - /* this is a fatal error */ - *errnop = errno = ENOMEM; - ret = NSS_STATUS_UNAVAIL; - goto done; - } - /* 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); + _LDB_NSS_GRGID_FILTER, gid); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -340,7 +318,6 @@ done: NSS_STATUS _nss_ldb_initgroups_dyn(const char *user, gid_t group, long int *start, long int *size, gid_t **groups, long int limit, int *errnop) { int ret; - char *filter; const char * attrs[] = { "uidNumber", "gidNumber", NULL }; struct ldb_result *uid_res; struct ldb_result *mem_res; @@ -356,22 +333,12 @@ NSS_STATUS _nss_ldb_initgroups_dyn(const char *user, gid_t group, long int *star return NSS_STATUS_UNAVAIL; } - /* build the filter for this name */ - filter = talloc_asprintf(mem_res, _LDB_NSS_PWNAM_FILTER, user); - if (filter == NULL) { - /* this is a fatal error */ - *errnop = errno = ENOENT; - ret = NSS_STATUS_UNAVAIL; - goto done; - } - /* 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); + _LDB_NSS_PWNAM_FILTER, user); 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..2e7ec456b3 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; } @@ -113,7 +113,6 @@ NSS_STATUS _nss_ldb_getpwent_r(struct passwd *result_buf, NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffer, size_t buflen, int *errnop) { int ret; - char *filter; struct ldb_result *res; if (uid == 0) { /* we don't serve root uid by policy */ @@ -126,22 +125,12 @@ NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffe return ret; } - /* build the filter for this uid */ - filter = talloc_asprintf(_ldb_nss_ctx, _LDB_NSS_PWUID_FILTER, uid); - if (filter == NULL) { - /* this is a fatal error */ - *errnop = errno = ENOMEM; - ret = NSS_STATUS_UNAVAIL; - goto done; - } - /* 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); + _LDB_NSS_PWUID_FILTER, uid); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -171,7 +160,6 @@ NSS_STATUS _nss_ldb_getpwuid_r(uid_t uid, struct passwd *result_buf, char *buffe res->msgs[0]); done: - talloc_free(filter); talloc_free(res); return ret; } @@ -179,7 +167,6 @@ done: NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char *buffer, size_t buflen, int *errnop) { int ret; - char *filter; struct ldb_result *res; ret = _ldb_nss_init(); @@ -187,22 +174,12 @@ NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char return ret; } - /* build the filter for this name */ - filter = talloc_asprintf(_ldb_nss_ctx, _LDB_NSS_PWNAM_FILTER, name); - if (filter == NULL) { - /* this is a fatal error */ - *errnop = errno = ENOENT; - ret = NSS_STATUS_UNAVAIL; - goto done; - } - /* 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); + _LDB_NSS_PWNAM_FILTER, name); if (ret != LDB_SUCCESS) { /* this is a fatal error */ *errnop = errno = ENOENT; @@ -232,7 +209,6 @@ NSS_STATUS _nss_ldb_getpwnam_r(const char *name, struct passwd *result_buf, char res->msgs[0]); done: - talloc_free(filter); talloc_free(res); return ret; } diff --git a/source3/lib/ldb/tools/ad2oLschema.c b/source3/lib/ldb/tools/ad2oLschema.c index fc51cb12d8..0f05448a9e 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; @@ -119,13 +118,10 @@ static int fetch_oc_recursive(struct ldb_context *ldb, struct ldb_dn *schemadn, struct ldb_result *res; const char *name = ldb_msg_find_attr_as_string(search_from->msgs[i], "lDAPDisplayname", NULL); - 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); - talloc_free(filter); + ret = ldb_search(ldb, ldb, &res, schemadn, LDB_SCOPE_SUBTREE, + oc_attrs, "(&(&(objectClass=classSchema)(subClassOf=%s))(!(lDAPDisplayName=%s)))", + name, name); if (ret != LDB_SUCCESS) { printf("Search failed: %s\n", ldb_errstring(ldb)); return ret; @@ -165,9 +161,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 +202,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..a33e6ae704 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, "%s", 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..5e8ef1b21c 100644 --- a/source3/lib/ldb/tools/ldbtest.c +++ b/source3/lib/ldb/tools/ldbtest.c @@ -220,20 +220,18 @@ static void search_uid(struct ldb_context *ldb, struct ldb_dn *basedn, int nreco for (i=0;i<nsearches;i++) { int uid = (i * 700 + 17) % (nrecords * 2); - char *expr; struct ldb_result *res = NULL; 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, "(uid=TEST%d)", uid); if (ret != LDB_SUCCESS || (uid < nrecords && res->count != 1)) { - printf("Failed to find %s - %s\n", expr, ldb_errstring(ldb)); + printf("Failed to find TEST%d - %s\n", uid, ldb_errstring(ldb)); exit(1); } if (uid >= nrecords && res->count > 0) { - printf("Found %s !? - %d\n", expr, ret); + printf("Found TEST%d !? - %d\n", uid, ret); exit(1); } @@ -345,7 +343,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); |