s4-dsdb: setup a one_way_link attribute on schema attributes
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Aug 2011 03:54:58 +0000 (13:54 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 4 Aug 2011 06:17:24 +0000 (16:17 +1000)
this allows us to quickly determine if a DN is a one way link

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>

source4/dsdb/schema/schema.h
source4/dsdb/schema/schema_inferiors.c

index 75351798c223985e6a8fefa1caff13bc33df2a19..289fd4276c85b8b739010b789862c051a89c2436 100644 (file)
@@ -107,6 +107,8 @@ struct dsdb_attribute {
        bool isDefunct;
        bool systemOnly;
 
+       bool one_way_link;
+
        /* internal stuff */
        const struct dsdb_syntax *syntax;
        const struct ldb_schema_attribute *ldb_schema_attribute;
index d2c134ea9e911853fc95bf15cd11d5414ce2b7aa..7b80c20a60605e7945e482594b6be09bc56b10e5 100644 (file)
@@ -328,6 +328,7 @@ int schema_fill_constructed(const struct dsdb_schema *schema)
 {
        int ret;
        struct dsdb_class *schema_class;
+       struct dsdb_attribute *attribute;
 
        schema_fill_from_ids(schema);
 
@@ -353,5 +354,32 @@ int schema_fill_constructed(const struct dsdb_schema *schema)
                schema_class->posssuperiors = NULL;
        }
 
+       /* setup fast access to one_way_link */
+       for (attribute=schema->attributes; attribute; attribute=attribute->next) {
+               if (dsdb_dn_oid_to_format(attribute->syntax->ldap_oid) == 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;
 }