diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-09-15 08:14:54 -0700 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-09-15 10:38:52 -0700 |
commit | 9a209ac252508bc9a5b1eaaaf256610aceb37736 (patch) | |
tree | 10df74943d8add501a89611f0e4d87eaf6c94e2c | |
parent | 231b2fa26139a38bb67b3777c80b72e2f9d6d904 (diff) | |
download | samba-9a209ac252508bc9a5b1eaaaf256610aceb37736.tar.gz samba-9a209ac252508bc9a5b1eaaaf256610aceb37736.tar.bz2 samba-9a209ac252508bc9a5b1eaaaf256610aceb37736.zip |
s4:schema Add code to provide an index into the subClass tree
In time, this should avoid the astounding (order) complexity of the
objectclass sorting in objectclass.c eventually.
Andrew Bartlett
-rw-r--r-- | source4/dsdb/schema/schema.h | 7 | ||||
-rw-r--r-- | source4/dsdb/schema/schema_inferiors.c | 21 |
2 files changed, 27 insertions, 1 deletions
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h index a605e2f707..4e7e503931 100644 --- a/source4/dsdb/schema/schema.h +++ b/source4/dsdb/schema/schema.h @@ -146,6 +146,13 @@ struct dsdb_class { uint32_t *mustContain_ids; uint32_t *mayContain_ids; uint32_t *systemPossSuperiors_ids; + + /* An ordered index showing how this subClass fits into the + * subClass tree. that is, an objectclass that is not + * subClassOf anything is 0 (just in case), and top is 1, and + * subClasses of top are 2, subclasses of those classes are + * 3 */ + uint32_t subClass_order; }; struct dsdb_schema_oid_prefix { diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c index b0ecc08600..493b425b72 100644 --- a/source4/dsdb/schema/schema_inferiors.c +++ b/source4/dsdb/schema/schema_inferiors.c @@ -127,6 +127,20 @@ static char **schema_subclasses_recurse(struct dsdb_schema *schema, struct dsdb_ return list; } +/* Walk down the subClass tree, setting a higher index as we go down + * each level. top is 1, subclasses of top are 2, etc */ +void schema_subclasses_order_recurse(struct dsdb_schema *schema, struct dsdb_class *schema_class, int order) +{ + const char **list = schema_class->subclasses_direct; + int i; + schema_class->subClass_order = order; + for (i=0;list && list[i]; i++) { + struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]); + schema_subclasses_order_recurse(schema, schema_class2, order+1); + } + return; +} + static void schema_create_subclasses(struct dsdb_schema *schema) { struct dsdb_class *schema_class; @@ -148,7 +162,12 @@ static void schema_create_subclasses(struct dsdb_schema *schema) for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) { schema_class->subclasses = str_list_unique(schema_subclasses_recurse(schema, schema_class)); - } + + /* Initilise the subClass order, to ensure we can't have uninitilised sort on the subClass hirarchy */ + schema_class->subClass_order = 0; + } + + schema_subclasses_order_recurse(schema, dsdb_class_by_lDAPDisplayName(schema, "top"), 1); } static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct dsdb_class *schema_class) |