s4-dsdb: ensure we setup the dn_format field in schema attributes
authorAndrew Tridgell <tridge@samba.org>
Tue, 9 Aug 2011 01:47:25 +0000 (11:47 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 9 Aug 2011 09:56:23 +0000 (11:56 +0200)
this ensures we setup dn_format when we do runtime schema changes

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/schema/schema_inferiors.c
source4/dsdb/schema/schema_set.c

index fe456412d1fc1a9a08666e0dbd37fa4e2d93c2a1..d2c134ea9e911853fc95bf15cd11d5414ce2b7aa 100644 (file)
@@ -328,7 +328,6 @@ int schema_fill_constructed(const struct dsdb_schema *schema)
 {
        int ret;
        struct dsdb_class *schema_class;
 {
        int ret;
        struct dsdb_class *schema_class;
-       struct dsdb_attribute *attribute;
 
        schema_fill_from_ids(schema);
 
 
        schema_fill_from_ids(schema);
 
@@ -354,35 +353,5 @@ int schema_fill_constructed(const struct dsdb_schema *schema)
                schema_class->posssuperiors = NULL;
        }
 
                schema_class->posssuperiors = NULL;
        }
 
-       /* setup fast access to one_way_link and DN format */
-       for (attribute=schema->attributes; attribute; attribute=attribute->next) {
-               attribute->dn_format = dsdb_dn_oid_to_format(attribute->syntax->ldap_oid);
-
-               if (attribute->dn_format == DSDB_INVALID_DN) {
-                       attribute->one_way_link = false;
-                       continue;
-               }
-
-               /* these are not considered to be one way links for
-                  the purpose of DN link fixups */
-               if (ldb_attr_cmp("distinguishedName", attribute->lDAPDisplayName) == 0 ||
-                   ldb_attr_cmp("objectCategory", attribute->lDAPDisplayName) == 0) {
-                       attribute->one_way_link = false;
-                       continue;
-               }
-
-               if (attribute->linkID == 0) {
-                       attribute->one_way_link = true;
-                       continue;
-               }
-               /* handle attributes with a linkID but no backlink */
-               if (dsdb_attribute_by_linkID(schema, attribute->linkID) == NULL) {
-                       attribute->one_way_link = true;
-                       continue;
-               }
-               attribute->one_way_link = false;
-       }
-
-
        return LDB_SUCCESS;
 }
        return LDB_SUCCESS;
 }
index 9dee0a4eecdc533d1f8a75b7a19d56b6521f038c..1c1e45ef78844bada9469f4181b5e9c7c606841e 100644 (file)
@@ -200,6 +200,44 @@ op_error:
        return ldb_operr(ldb);
 }
 
        return ldb_operr(ldb);
 }
 
+
+/*
+  create extra attribute shortcuts
+ */
+static void dsdb_setup_attribute_shortcuts(struct ldb_context *ldb, struct dsdb_schema *schema)
+{
+       struct dsdb_attribute *attribute;
+
+       /* setup fast access to one_way_link and DN format */
+       for (attribute=schema->attributes; attribute; attribute=attribute->next) {
+               attribute->dn_format = dsdb_dn_oid_to_format(attribute->syntax->ldap_oid);
+
+               if (attribute->dn_format == DSDB_INVALID_DN) {
+                       attribute->one_way_link = false;
+                       continue;
+               }
+
+               /* these are not considered to be one way links for
+                  the purpose of DN link fixups */
+               if (ldb_attr_cmp("distinguishedName", attribute->lDAPDisplayName) == 0 ||
+                   ldb_attr_cmp("objectCategory", attribute->lDAPDisplayName) == 0) {
+                       attribute->one_way_link = false;
+                       continue;
+               }
+
+               if (attribute->linkID == 0) {
+                       attribute->one_way_link = true;
+                       continue;
+               }
+               /* handle attributes with a linkID but no backlink */
+               if (dsdb_attribute_by_linkID(schema, attribute->linkID) == NULL) {
+                       attribute->one_way_link = true;
+                       continue;
+               }
+               attribute->one_way_link = false;
+       }
+}
+
 static int uint32_cmp(uint32_t c1, uint32_t c2)
 {
        if (c1 == c2) return 0;
 static int uint32_cmp(uint32_t c1, uint32_t c2)
 {
        if (c1 == c2) return 0;
@@ -354,6 +392,8 @@ int dsdb_setup_sorted_accessors(struct ldb_context *ldb,
        TYPESAFE_QSORT(schema->attributes_by_attributeID_oid, schema->num_attributes, dsdb_compare_attribute_by_attributeID_oid);
        TYPESAFE_QSORT(schema->attributes_by_linkID, schema->num_attributes, dsdb_compare_attribute_by_linkID);
 
        TYPESAFE_QSORT(schema->attributes_by_attributeID_oid, schema->num_attributes, dsdb_compare_attribute_by_attributeID_oid);
        TYPESAFE_QSORT(schema->attributes_by_linkID, schema->num_attributes, dsdb_compare_attribute_by_linkID);
 
+       dsdb_setup_attribute_shortcuts(ldb, schema);
+
        return LDB_SUCCESS;
 
 failed:
        return LDB_SUCCESS;
 
 failed: