summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_dn.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-17 23:03:41 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-18 21:03:39 +1100
commit82bf0d8bc6b4fa43f015b700a97f68f3d479eb36 (patch)
tree6bce367423fb82ae71ecfa6c5c01ce6b429bd214 /source4/lib/ldb/common/ldb_dn.c
parentdb76e6531825e66d4859106b583d9f7be8ae0a3a (diff)
downloadsamba-82bf0d8bc6b4fa43f015b700a97f68f3d479eb36.tar.gz
samba-82bf0d8bc6b4fa43f015b700a97f68f3d479eb36.tar.bz2
samba-82bf0d8bc6b4fa43f015b700a97f68f3d479eb36.zip
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 <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb/common/ldb_dn.c')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c23
1 files changed, 23 insertions, 0 deletions
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;
+}