summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-10 22:45:36 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-14 22:29:57 +1100
commit56b90acbf6ada4c9e2565770918673419b708479 (patch)
treeb2e588e15e1653056b20a6d3ae3230de33eba707 /source4
parenta3b7e84a65e3ddc94edc36fd1b4641849b9ee0be (diff)
downloadsamba-56b90acbf6ada4c9e2565770918673419b708479.tar.gz
samba-56b90acbf6ada4c9e2565770918673419b708479.tar.bz2
samba-56b90acbf6ada4c9e2565770918673419b708479.zip
s4-ldb: sort the linearized extended DN by component name
This will make life easier when handling deleted linked attributes
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 59a6dc0594..bd42bd5f18 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -789,6 +789,13 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
return dn->linearized;
}
+static int ldb_dn_extended_component_compare(const void *p1, const void *p2)
+{
+ const struct ldb_dn_ext_component *ec1 = (const struct ldb_dn_ext_component *)p1;
+ const struct ldb_dn_ext_component *ec2 = (const struct ldb_dn_ext_component *)p2;
+ return strcmp(ec1->name, ec2->name);
+}
+
char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
{
const char *linearized = ldb_dn_get_linearized(dn);
@@ -807,6 +814,13 @@ char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode)
return NULL;
}
+ /* sort the extended components by name. The idea is to make
+ * the resulting DNs consistent, plus to ensure that we put
+ * 'DELETED' first, so it can be very quickly recognised
+ */
+ qsort(dn->ext_components, dn->ext_comp_num, sizeof(dn->ext_components[0]),
+ ldb_dn_extended_component_compare);
+
for (i = 0; i < dn->ext_comp_num; i++) {
const struct ldb_dn_extended_syntax *ext_syntax;
const char *name = dn->ext_components[i].name;