1
0
mirror of https://github.com/samba-team/samba.git synced 2025-10-23 11:33:16 +03:00

r17648: 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
This commit is contained in:
Simo Sorce
2006-08-21 03:52:43 +00:00
committed by Gerald (Jerry) Carter
parent e32fdc7e68
commit 8dd1c1c05b
2 changed files with 51 additions and 13 deletions

View File

@@ -184,7 +184,13 @@ static struct MprVar mprLdbMessage(struct ldb_context *ldb, struct ldb_message *
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 @@ static struct MprVar mprLdbMessage(struct ldb_context *ldb, struct ldb_message *
&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);

View File

@@ -54,7 +54,7 @@ class_attrs = new Array("objectClass",
attrib_attrs = new Array("objectClass", "lDAPDisplayName",
"isSingleValued", "linkID", "systemFlags", "systemOnly",
"schemaIDGUID", "adminDisplayName", "attributeID",
"attributeSyntax");
"attributeSyntax", "oMSyntax", "oMObjectClass");
/*
notes:
@@ -75,21 +75,37 @@ function dprintf() {
}
}
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 fix_dn(dn) {
*/
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 @@ function find_attribute_properties(ldb, o) {
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 @@ function expand_objectclass(ldb, o) {
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 @@ function add_objectclass_attributes(ldb, class) {
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 @@ function walk_dn(ldb, dn) {
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 @@ function walk_naming_context(ldb, namingContext) {
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 @@ function build_objectclass(ldb, name) {
dprintf("unknown class '%s'\n", name);
return undefined;
}
return obj_objectClass(name);
return obj_objectClass(ldb, name);
}
/*