1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

dsdb: Use samdb_get_system_container_dn() to get Password Settings Container

By doing this we use the common samdb_get_system_container_dn() routine and we
avoid doing a linerize and parse step on the main DN, instead using the
already stored parse of the DN.  This is more hygenic.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9959

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Andrew Bartlett 2023-07-27 16:44:10 +12:00 committed by Stefan Metzmacher
parent 97b682e0eb
commit 3669caa97f

View File

@ -1009,19 +1009,20 @@ static int get_pso_count(struct ldb_module *module, TALLOC_CTX *mem_ctx,
{
static const char * const attrs[] = { NULL };
int ret;
struct ldb_dn *domain_dn = NULL;
struct ldb_dn *psc_dn = NULL;
struct ldb_result *res = NULL;
struct ldb_context *ldb = ldb_module_get_ctx(module);
bool psc_ok;
*pso_count = 0;
domain_dn = ldb_get_default_basedn(ldb);
psc_dn = ldb_dn_new_fmt(mem_ctx, ldb,
"CN=Password Settings Container,CN=System,%s",
ldb_dn_get_linearized(domain_dn));
psc_dn = samdb_system_container_dn(ldb, mem_ctx);
if (psc_dn == NULL) {
return ldb_oom(ldb);
}
psc_ok = ldb_dn_add_child_fmt(psc_dn, "CN=Password Settings Container");
if (psc_ok == false) {
return ldb_oom(ldb);
}
/* get the number of PSO children */
ret = dsdb_module_search(module, mem_ctx, &res, psc_dn,
@ -1088,8 +1089,8 @@ static int pso_search_by_sids(struct ldb_module *module, TALLOC_CTX *mem_ctx,
int i;
struct ldb_context *ldb = ldb_module_get_ctx(module);
char *sid_filter = NULL;
struct ldb_dn *domain_dn = NULL;
struct ldb_dn *psc_dn = NULL;
bool psc_ok;
const char *attrs[] = {
"msDS-PasswordSettingsPrecedence",
"objectGUID",
@ -1117,13 +1118,14 @@ static int pso_search_by_sids(struct ldb_module *module, TALLOC_CTX *mem_ctx,
}
/* only PSOs located in the Password Settings Container are valid */
domain_dn = ldb_get_default_basedn(ldb);
psc_dn = ldb_dn_new_fmt(mem_ctx, ldb,
"CN=Password Settings Container,CN=System,%s",
ldb_dn_get_linearized(domain_dn));
psc_dn = samdb_system_container_dn(ldb, mem_ctx);
if (psc_dn == NULL) {
return ldb_oom(ldb);
}
psc_ok = ldb_dn_add_child_fmt(psc_dn, "CN=Password Settings Container");
if (psc_ok == false) {
return ldb_oom(ldb);
}
ret = dsdb_module_search(module, mem_ctx, result, psc_dn,
LDB_SCOPE_ONELEVEL, attrs,