}
ldb_set_utf8_default(ldb);
- ldb_set_create_perms(ldb, 0666);
+ ldb_set_create_perms(ldb, 0600);
return 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");
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;
*_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,
done:
if (ret != LDB_SUCCESS) {
talloc_free(res);
+ res = NULL;
}
*_res = res;
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);