summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema/schema_inferiors.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-07-02 14:49:40 +1000
committerAndrew Tridgell <tridge@samba.org>2009-07-02 14:55:38 +1000
commitae8515d31b55bbe47b45aa2892d5d98000f645c4 (patch)
tree9fafda7de4e27b0e090df3749c07f96b157ed959 /source4/dsdb/schema/schema_inferiors.c
parent865ca9be64acc3bfd8bfaabb0621592234e07be7 (diff)
downloadsamba-ae8515d31b55bbe47b45aa2892d5d98000f645c4.tar.gz
fixed the pull of drs schema elements
The previous code incorrectly assumed that attributes such as subClassOf come over the wire as strings. In fact they come over as 32 bit integers which refer to goversIDs. We have to post-process these as it sometimes happens that a governsID comes over the wire before the record that defines what it means.
Diffstat (limited to 'source4/dsdb/schema/schema_inferiors.c')
-rw-r--r--source4/dsdb/schema/schema_inferiors.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c
index fc1845bb423..63ddb4a424e 100644
--- a/source4/dsdb/schema/schema_inferiors.c
+++ b/source4/dsdb/schema/schema_inferiors.c
@@ -166,10 +166,89 @@ static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct ds
schema_class->possibleInferiors = str_list_unique(schema_class->possibleInferiors);
}
+/*
+ fill in a string class name from a governs_ID
+ */
+static void schema_fill_from_class_one(struct dsdb_schema *schema, struct dsdb_class *c,
+ const char **s, uint32_t id)
+{
+ if (*s == NULL && id != 0) {
+ struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, id);
+ if (c2) {
+ *s = c2->lDAPDisplayName;
+ }
+ }
+}
+
+/*
+ fill in a list of string class names from a governs_ID list
+ */
+static void schema_fill_from_class_list(struct dsdb_schema *schema, struct dsdb_class *c,
+ const char ***s, uint32_t *ids)
+{
+ if (*s == NULL && ids != NULL) {
+ int i;
+ for (i=0;ids[i];i++) ;
+ *s = talloc_array(c, const char *, i+1);
+ for (i=0;ids[i];i++) {
+ struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, ids[i]);
+ if (c2) {
+ (*s)[i] = c2->lDAPDisplayName;
+ } else {
+ (*s)[i] = NULL;
+ }
+ }
+ (*s)[i] = NULL;
+ }
+}
+
+/*
+ fill in a list of string attribute names from a attributeID list
+ */
+static void schema_fill_from_attribute_list(struct dsdb_schema *schema, struct dsdb_class *c,
+ const char ***s, uint32_t *ids)
+{
+ if (*s == NULL && ids != NULL) {
+ int i;
+ for (i=0;ids[i];i++) ;
+ *s = talloc_array(c, const char *, i+1);
+ for (i=0;ids[i];i++) {
+ struct dsdb_attribute *a = dsdb_attribute_by_attributeID_id(schema, ids[i]);
+ if (a) {
+ (*s)[i] = a->lDAPDisplayName;
+ } else {
+ (*s)[i] = NULL;
+ }
+ }
+ (*s)[i] = NULL;
+ }
+}
+
+/*
+ if the schema came from DRS then some attributes will be setup as IDs
+ */
+static void schema_fill_from_ids(struct dsdb_schema *schema)
+{
+ struct dsdb_class *c;
+ for (c=schema->classes; c; c=c->next) {
+ schema_fill_from_class_one(schema, c, &c->subClassOf, c->subClassOf_id);
+ schema_fill_from_attribute_list(schema, c, &c->systemMayContain, c->systemMayContain_ids);
+ schema_fill_from_attribute_list(schema, c, &c->systemMustContain, c->systemMustContain_ids);
+ schema_fill_from_attribute_list(schema, c, &c->mustContain, c->mustContain_ids);
+ schema_fill_from_attribute_list(schema, c, &c->mayContain, c->mayContain_ids);
+ schema_fill_from_class_list(schema, c, &c->possSuperiors, c->possSuperiors_ids);
+ schema_fill_from_class_list(schema, c, &c->systemPossSuperiors, c->systemPossSuperiors_ids);
+ schema_fill_from_class_list(schema, c, &c->systemAuxiliaryClass, c->systemAuxiliaryClass_ids);
+ schema_fill_from_class_list(schema, c, &c->auxiliaryClass, c->auxiliaryClass_ids);
+ }
+}
+
void schema_fill_constructed(struct dsdb_schema *schema)
{
struct dsdb_class *schema_class;
+ schema_fill_from_ids(schema);
+
schema_create_subclasses(schema);
for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {