1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

s4:"samdb_search_count" - introduce a "mem_ctx" parameter

All other "samdb_search_*" calls do have one - why "samdb_search_count" doesn't?

Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Mon Oct 25 17:42:33 UTC 2010 on sn-devel-104
This commit is contained in:
Matthias Dieter Wallnöfer 2010-10-25 18:14:02 +02:00
parent fd7943bc80
commit 6fb64b9c7a
3 changed files with 12 additions and 10 deletions

View File

@ -192,18 +192,17 @@ struct dom_sid *samdb_search_dom_sid(struct ldb_context *sam_ldb,
return the count of the number of records in the sam matching the query
*/
int samdb_search_count(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
struct ldb_dn *basedn,
const char *format, ...) _PRINTF_ATTRIBUTE(3,4)
const char *format, ...) _PRINTF_ATTRIBUTE(4,5)
{
va_list ap;
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, NULL, attrs, format, ap);
ret = gendb_search_v(sam_ldb, mem_ctx, basedn, NULL, attrs, format, ap);
va_end(ap);
talloc_free(tmp_ctx);
return ret;
}
@ -1870,7 +1869,7 @@ const char *samdb_client_site_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
* is for sure the same as our server site). If more sites do
* exist then we don't know which one to use and set the site
* name to "". */
cnt = samdb_search_count(ldb, sites_container_dn,
cnt = samdb_search_count(ldb, mem_ctx, sites_container_dn,
"(objectClass=site)");
if (cnt == 1) {
site_name = samdb_server_site_name(ldb, mem_ctx);

View File

@ -180,7 +180,7 @@ static int samldb_check_sAMAccountName(struct samldb_ctx *ac)
return ldb_operr(ldb);
}
ret = samdb_search_count(ldb, NULL, "(sAMAccountName=%s)",
ret = samdb_search_count(ldb, ac, NULL, "(sAMAccountName=%s)",
ldb_binary_encode_string(ac, name));
if ((ret < 0) || (ret > 1)) {
return ldb_operr(ldb);
@ -1523,7 +1523,7 @@ static int samldb_prim_group_users_check(struct samldb_ctx *ac)
}
/* Deny delete requests from groups which are primary ones */
count = samdb_search_count(ldb, NULL,
count = samdb_search_count(ldb, ac, NULL,
"(&(primaryGroupID=%u)(objectClass=user))",
rid);
if (count < 0) {

View File

@ -520,12 +520,15 @@ static NTSTATUS dcesrv_samr_info_DomGeneralInformation(struct samr_domain_state
}
/* No users in BUILTIN, and the LOCAL group types are only in builtin, and the global group type is never in BUILTIN */
info->num_users = samdb_search_count(state->sam_ctx, state->domain_dn,
info->num_users = samdb_search_count(state->sam_ctx, mem_ctx,
state->domain_dn,
"(objectClass=user)");
info->num_groups = samdb_search_count(state->sam_ctx, state->domain_dn,
info->num_groups = samdb_search_count(state->sam_ctx, mem_ctx,
state->domain_dn,
"(&(objectClass=group)(groupType=%u))",
GTYPE_SECURITY_GLOBAL_GROUP);
info->num_aliases = samdb_search_count(state->sam_ctx, state->domain_dn,
info->num_aliases = samdb_search_count(state->sam_ctx, mem_ctx,
state->domain_dn,
"(&(objectClass=group)(groupType=%u))",
GTYPE_SECURITY_DOMAIN_LOCAL_GROUP);