summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-10-13 07:47:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:48 -0500
commit52cc7a55018c0a8243e4b7e35206bd9d3616abd8 (patch)
tree71caca30737e1fef0b067b40761140615ae28f2b /source4
parent6b7d7f22e754cb8a580951ae3626bb91d4642c75 (diff)
downloadsamba-52cc7a55018c0a8243e4b7e35206bd9d3616abd8.tar.gz
samba-52cc7a55018c0a8243e4b7e35206bd9d3616abd8.tar.bz2
samba-52cc7a55018c0a8243e4b7e35206bd9d3616abd8.zip
r10956: Tridge thought some comments might be a good idea :-)
Andrew Bartlett (This used to be commit c0d6126effdf31e0a107c06a400973c731e0e263)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index abe8985f9d..5895432431 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -839,9 +839,19 @@ struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn)
return rdn;
}
+/* Create a 'canonical name' string from a DN:
+
+ ie dc=samba,dc=org -> samba.org/
+ uid=administrator,ou=users,dc=samba,dc=org = samba.org/users/administrator
+
+ There are two formats, the EX format has the last / replaced with a newline (\n).
+
+*/
static char *ldb_dn_canonical(void *mem_ctx, const struct ldb_dn *dn, int ex_format) {
int i;
char *cracked = NULL;
+
+ /* Walk backwards down the DN, grabbing 'dc' components at first */
for (i = dn->comp_num - 1 ; i >= 0; i--) {
if (strcasecmp(dn->components[i].name, "dc") != 0) {
break;
@@ -857,7 +867,7 @@ static char *ldb_dn_canonical(void *mem_ctx, const struct ldb_dn *dn, int ex_for
}
}
- /* Only domain components */
+ /* Only domain components? Finish here */
if (i < 0) {
if (ex_format) {
cracked = talloc_asprintf(mem_ctx, "%s\n", cracked);
@@ -867,6 +877,7 @@ static char *ldb_dn_canonical(void *mem_ctx, const struct ldb_dn *dn, int ex_for
return cracked;
}
+ /* Now walk backwards appending remaining components */
for (; i > 0; i--) {
cracked = talloc_asprintf(mem_ctx, "%s/%s", cracked,
dn->components[i].value.data);
@@ -875,7 +886,7 @@ static char *ldb_dn_canonical(void *mem_ctx, const struct ldb_dn *dn, int ex_for
}
}
- /* Last one */
+ /* Last one, possibly a newline for the 'ex' format */
if (ex_format) {
cracked = talloc_asprintf(mem_ctx, "%s\n%s", cracked,
dn->components[i].value.data);
@@ -886,6 +897,7 @@ static char *ldb_dn_canonical(void *mem_ctx, const struct ldb_dn *dn, int ex_for
return cracked;
}
+/* Wrapper functions for the above, for the two different string formats */
char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn) {
return ldb_dn_canonical(mem_ctx, dn, 0);