svn commit: samba r17648 - in branches/SAMBA_4_0: source/scripting/ejs testprogs/ejs

idra at samba.org idra at samba.org
Mon Aug 21 03:52:44 GMT 2006


Author: idra
Date: 2006-08-21 03:52:43 +0000 (Mon, 21 Aug 2006)
New Revision: 17648

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

Log:

update minschema.js
this version returns also oMSyntax and oMObjectClass and also
use the right value for the objects CNs

add a nasty hack to ejs' mprLdbMessage() to handle binary blobs situations


Modified:
   branches/SAMBA_4_0/source/scripting/ejs/mprutil.c
   branches/SAMBA_4_0/testprogs/ejs/minschema.js


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/mprutil.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/mprutil.c	2006-08-21 03:51:55 UTC (rev 17647)
+++ branches/SAMBA_4_0/source/scripting/ejs/mprutil.c	2006-08-21 03:52:43 UTC (rev 17648)
@@ -184,7 +184,13 @@
 			if (attr->ldif_write_fn(ldb, msg, &el->values[0], &v) != 0) {
 				goto failed;
 			}
-			val = mprData(v.data, v.length);
+			/* FIXME: nasty hack, remove me when ejs will support
+			 * arbitrary string and does not truncate on \0 */
+			if (strlen((char *)v.data) != v.length) {
+				val = mprDataBlob(v);
+			} else {
+				val = mprData(v.data, v.length);
+			}
 		} else {
 			int j;
 			val = mprArray(el->name);
@@ -193,7 +199,13 @@
 							&el->values[j], &v) != 0) {
 					goto failed;
 				}
-				mprAddArray(&val, j, mprData(v.data, v.length));
+				/* FIXME: nasty hack, remove me when ejs will support
+				 * arbitrary string and does not truncate on \0 */
+				if (strlen((char *)v.data) != v.length) {
+					mprAddArray(&val, j, mprDataBlob(v));
+				} else {
+					mprAddArray(&val, j, mprData(v.data, v.length));
+				}
 			}
 		}
 		mprSetVar(&var, el->name, val);

Modified: branches/SAMBA_4_0/testprogs/ejs/minschema.js
===================================================================
--- branches/SAMBA_4_0/testprogs/ejs/minschema.js	2006-08-21 03:51:55 UTC (rev 17647)
+++ branches/SAMBA_4_0/testprogs/ejs/minschema.js	2006-08-21 03:52:43 UTC (rev 17648)
@@ -54,7 +54,7 @@
 attrib_attrs = new Array("objectClass", "lDAPDisplayName", 
 			 "isSingleValued", "linkID", "systemFlags", "systemOnly",
 			 "schemaIDGUID", "adminDisplayName", "attributeID",
-			 "attributeSyntax");
+			 "attributeSyntax", "oMSyntax", "oMObjectClass");
 
 /*
   notes:
@@ -75,21 +75,37 @@
 	}
 }
 
+function get_object_cn(ldb, name) {
+	var attrs = new Array("cn");
+
+	var res = ldb.search(sprintf("(ldapDisplayName=%s)", name), rootDse.schemaNamingContext, ldb.SCOPE_SUBTREE, attrs);
+	assert(res != undefined);
+	assert(res.length == 1);
+
+        var cn = res[0]["cn"];
+	assert(cn != undefined);
+	if (typeof(cn) == "string") {
+		return cn;
+	}
+	return cn[0];
+}
 /*
   create an objectclass object
 */
-function obj_objectClass(name) {
+function obj_objectClass(ldb, name) {
 	var o = new Object();
 	o.name = name;
+	o.cn = get_object_cn(ldb, name);
 	return o;
 }
 
 /*
   create an attribute object
 */
-function obj_attribute(name) {
+function obj_attribute(ldb, name) {
 	var o = new Object();
 	o.name = name;
+	o.cn = get_object_cn(ldb, name);
 	return o;
 }
 
@@ -142,14 +158,19 @@
 */
 function write_ldif_one(o, attrs) {
 	var i;
-	printf("dn: CN=%s,CN=Schema,CN=Configuration,${BASEDN}\n", o.name);
-	printf("cn: %s\n", o.name);
-	printf("name: %s\n", o.name);
+	printf("dn: CN=%s,CN=Schema,CN=Configuration,${BASEDN}\n", o.cn);
+	printf("cn: %s\n", o.cn);
+	printf("name: %s\n", o.cn);
 	for (i=0;i<attrs.length;i++) {
 		var a = attrs[i];
 		if (o[a] == undefined) {
 			continue;
 		}
+		/* special case for oMObjectClass, which is a binary object */
+		if (a == "oMObjectClass") {
+			printf("%s:: %s\n", a, o[a]);
+			continue;
+		}
 		var v = o[a];
 		if (typeof(v) == "string") {
 			v = new Array(v);
@@ -211,6 +232,11 @@
 	var msg = res[0];
 	var a;
 	for (a in msg) {
+		/* special case for oMObjectClass, which is a binary object */
+		if (a == "oMObjectClass") {
+			o[a] = ldb.encode(msg[a]);
+			continue;
+		}
 		o[a] = msg[a];
 	}
 }
@@ -278,7 +304,7 @@
 			var name = list[i];
 			if (objectclasses[name] == undefined) {
 				dprintf("Found new objectclass '%s'\n", name);
-				objectclasses[name] = obj_objectClass(name);
+				objectclasses[name] = obj_objectClass(ldb, name);
 			}
 		}
 	}
@@ -307,7 +333,7 @@
 		for (j=0;j<len;j++) {
 			var a = alist[j];
 			if (attributes[a] == undefined) {
-				attributes[a] = obj_attribute(a);
+				attributes[a] = obj_attribute(ldb, a);
 			}
 		}
 	}
@@ -337,7 +363,7 @@
 	var msg = res[0];
 	for (a in msg) {
 		if (attributes[a] == undefined) {
-			attributes[a] = obj_attribute(a);
+			attributes[a] = obj_attribute(ldb, a);
 		}
 	}
 }
@@ -360,7 +386,7 @@
 		for (c=0;c<msg.length;c++) {
 			var objectClass = msg[c];
 			if (objectclasses[objectClass] == undefined) {
-				objectclasses[objectClass] = obj_objectClass(objectClass);
+				objectclasses[objectClass] = obj_objectClass(ldb, objectClass);
 				objectclasses[objectClass].exampleDN = res[r].dn;
 			}
 		}
@@ -391,7 +417,7 @@
 		dprintf("unknown class '%s'\n", name);
 		return undefined;
 	}
-	return obj_objectClass(name);
+	return obj_objectClass(ldb, name);
 }
 
 /*



More information about the samba-cvs mailing list