svn commit: samba r10956 - in branches/SAMBA_4_0/source/lib/ldb/common: .

abartlet at samba.org abartlet at samba.org
Thu Oct 13 07:47:57 GMT 2005


Author: abartlet
Date: 2005-10-13 07:47:57 +0000 (Thu, 13 Oct 2005)
New Revision: 10956

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10956

Log:
Tridge thought some comments might be a good idea :-)

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c	2005-10-13 06:09:37 UTC (rev 10955)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c	2005-10-13 07:47:57 UTC (rev 10956)
@@ -839,9 +839,19 @@
 	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 @@
 		}
 	}
 
-	/* 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 @@
 		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 @@
 		}
 	}
 
-	/* 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 @@
 	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);
 



More information about the samba-cvs mailing list