mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ldb:gendb_* calls: support a "NULL" resultset parameter
This is useful for "samdb_search_count" where only the amount of entries matters.
This commit is contained in:
parent
8bc2b54c72
commit
fd7943bc80
@ -55,22 +55,23 @@ int gendb_search_v(struct ldb_context *ldb,
|
||||
expr?"%s":NULL, expr);
|
||||
|
||||
if (ret == LDB_SUCCESS) {
|
||||
talloc_steal(mem_ctx, res->msgs);
|
||||
|
||||
DEBUG(6,("gendb_search_v: %s %s -> %d\n",
|
||||
basedn?ldb_dn_get_linearized(basedn):"NULL",
|
||||
expr?expr:"NULL", res->count));
|
||||
|
||||
ret = res->count;
|
||||
*msgs = res->msgs;
|
||||
if (msgs != NULL) {
|
||||
*msgs = talloc_steal(mem_ctx, res->msgs);
|
||||
}
|
||||
talloc_free(res);
|
||||
} else if (scope == LDB_SCOPE_BASE && ret == LDB_ERR_NO_SUCH_OBJECT) {
|
||||
ret = 0;
|
||||
*msgs = NULL;
|
||||
if (msgs != NULL) *msgs = NULL;
|
||||
} else {
|
||||
DEBUG(4,("gendb_search_v: search failed: %s\n",
|
||||
ldb_errstring(ldb)));
|
||||
ret = -1;
|
||||
if (msgs != NULL) *msgs = NULL;
|
||||
}
|
||||
|
||||
talloc_free(expr);
|
||||
|
@ -196,13 +196,12 @@ int samdb_search_count(struct ldb_context *sam_ldb,
|
||||
const char *format, ...) _PRINTF_ATTRIBUTE(3,4)
|
||||
{
|
||||
va_list ap;
|
||||
struct ldb_message **res;
|
||||
const char *attrs[] = { NULL };
|
||||
int ret;
|
||||
TALLOC_CTX *tmp_ctx = talloc_new(sam_ldb);
|
||||
|
||||
va_start(ap, format);
|
||||
ret = gendb_search_v(sam_ldb, tmp_ctx, basedn, &res, attrs, format, ap);
|
||||
ret = gendb_search_v(sam_ldb, tmp_ctx, basedn, NULL, attrs, format, ap);
|
||||
va_end(ap);
|
||||
talloc_free(tmp_ctx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user