diff options
author | Andrew Bartlett <abartlet@samba.org> | 2022-12-12 09:47:36 +1300 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2023-01-31 12:50:33 +0000 |
commit | aee2039e63ceeb5e69a0461fb77e0f18278e4dc4 (patch) | |
tree | 9148494049d9491084fdd85a3f095415e0d9c097 /source4/dsdb/common/dsdb_dn.c | |
parent | e96dfc74b3ece40fe64a33aa8b8d810b576982bd (diff) | |
download | samba-aee2039e63ceeb5e69a0461fb77e0f18278e4dc4.tar.gz |
s4-dsdb: rework drs_ObjectIdentifier_to_dn() into drs_ObjectIdentifier_to_dn_and_nc_root()
This make this funciton the gatekeeper between the wire format and the
internal struct ldb_dn, checking if the DN exists and which NC
it belongs to along the way, and presenting only a DB-returned
DN for internal processing.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10635
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb/common/dsdb_dn.c')
-rw-r--r-- | source4/dsdb/common/dsdb_dn.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source4/dsdb/common/dsdb_dn.c b/source4/dsdb/common/dsdb_dn.c index e348ab6aa94..04aab1593b1 100644 --- a/source4/dsdb/common/dsdb_dn.c +++ b/source4/dsdb/common/dsdb_dn.c @@ -396,3 +396,36 @@ struct ldb_dn *drs_ObjectIdentifier_to_dn(TALLOC_CTX *mem_ctx, talloc_free(dn_string); return new_dn; } + +/* + * Safely convert a drsuapi_DsReplicaObjectIdentifier into a validated + * LDB DN of an existing DB entry, and/or find the NC root + * + * Finally, we must return the DN as found in the DB, as otherwise a + * subsequence ldb_dn_compare(dn, nc_root) will fail (as this is based + * on the string components). + */ +int drs_ObjectIdentifier_to_dn_and_nc_root(TALLOC_CTX *mem_ctx, + struct ldb_context *ldb, + struct drsuapi_DsReplicaObjectIdentifier *nc, + struct ldb_dn **normalised_dn, + struct ldb_dn **nc_root) +{ + int ret; + struct ldb_dn *new_dn = NULL; + + new_dn = drs_ObjectIdentifier_to_dn(mem_ctx, + ldb, + nc); + if (new_dn == NULL) { + return LDB_ERR_INVALID_DN_SYNTAX; + } + + ret = dsdb_normalise_dn_and_find_nc_root(ldb, + mem_ctx, + new_dn, + normalised_dn, + nc_root); + TALLOC_FREE(new_dn); + return ret; +} |