From 82bf0d8bc6b4fa43f015b700a97f68f3d479eb36 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Dec 2009 23:03:41 +1100 Subject: s4-dsdb: added ldb_dn_update_components() This is used to udpate just the DN components of a ldb_dn, leaving the other extended fields alone. It is needed to prevent linked attribute updates from removing other extended components. Pair-Programmed-With: Andrew Bartlett --- source4/lib/ldb/common/ldb_dn.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index f11ccf35d7..79953c6018 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -2001,3 +2001,26 @@ bool ldb_dn_is_null(struct ldb_dn *dn) return false; } +/* + this updates dn->components, taking the components from ref_dn. + This is used by code that wants to update the DN path of a DN + while not impacting on the extended DN components + */ +int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn) +{ + dn->components = talloc_realloc(dn, dn->components, + struct ldb_dn_component, ref_dn->comp_num); + if (!dn->components) { + return LDB_ERR_OPERATIONS_ERROR; + } + memcpy(dn->components, ref_dn->components, + sizeof(struct ldb_dn_component)*ref_dn->comp_num); + dn->comp_num = ref_dn->comp_num; + + talloc_free(dn->linearized); + talloc_free(dn->ext_linearized); + dn->ext_linearized = NULL; + dn->linearized = NULL; + + return LDB_SUCCESS; +} -- cgit