diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-08-20 15:46:46 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-08-20 15:46:46 +1000 |
commit | 6e5f2454acb6ad11e799faed834fb4937651737d (patch) | |
tree | c52ab8594e30ee6cbafa6a83e88eca9140c34698 | |
parent | add717dd0e5a4f68ec2a7f5a1e4c5226ddd22dad (diff) | |
download | samba-6e5f2454acb6ad11e799faed834fb4937651737d.tar.gz samba-6e5f2454acb6ad11e799faed834fb4937651737d.tar.bz2 samba-6e5f2454acb6ad11e799faed834fb4937651737d.zip |
Apply attributes (and their syntax) from the schema into ldb
This changes the @ATTRIBUTES record to be for bootstrapping only,
before we find the schema.
Andrew Bartlett
(This used to be commit 358477fcc041d5fb2e6ac5641c2f899cc49cfb69)
-rw-r--r-- | source4/dsdb/schema/schema_set.c | 49 | ||||
-rw-r--r-- | source4/setup/provision_init.ldif | 7 |
2 files changed, 56 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 431ea3da65..b8b39bd1d4 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -23,9 +23,48 @@ #include "includes.h" #include "dsdb/samdb/samdb.h" #include "lib/ldb/include/ldb_errors.h" +#include "lib/ldb/include/ldb_private.h" #include "lib/util/dlinklist.h" #include "param/param.h" + +static int schema_set_attributes(struct ldb_context *ldb, struct dsdb_schema *schema) +{ + int ret = LDB_SUCCESS; + + struct dsdb_attribute *attr; + + for (attr = schema->attributes; attr; attr = attr->next) { + const struct ldb_schema_syntax *s; + if (!attr->syntax) { + continue; + } + if (attr->syntax->ldb_syntax) { + ret = ldb_schema_attribute_add(ldb, attr->lDAPDisplayName, 0, + attr->syntax->ldb_syntax); + } else { + s = ldb_standard_syntax_by_name(ldb, attr->syntax->ldap_oid); + if (s) { + ret = ldb_schema_attribute_add_with_syntax(ldb, attr->lDAPDisplayName, 0, s); + } else { + s = ldb_samba_syntax_by_name(ldb, attr->syntax->ldap_oid); + if (s) { + ret = ldb_schema_attribute_add_with_syntax(ldb, attr->lDAPDisplayName, 0, s); + } else { + ret = LDB_SUCCESS; /* Nothing to do here */ + } + } + } + if (ret != LDB_SUCCESS) { + return ret; + } + } + + /* Now put back the hardcoded Samba special handlers */ + return ldb_register_samba_handlers(ldb); +} + + /** * Attach the schema to an opaque pointer on the ldb, so ldb modules * can find it @@ -40,6 +79,11 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema) return ret; } + ret = schema_set_attributes(ldb, schema); + if (ret != LDB_SUCCESS) { + return ret; + } + talloc_steal(ldb, schema); return LDB_SUCCESS; @@ -64,6 +108,11 @@ int dsdb_set_global_schema(struct ldb_context *ldb) return ret; } + ret = schema_set_attributes(ldb, global_schema); + if (ret != LDB_SUCCESS) { + return ret; + } + /* Keep a reference to this schema, just incase the global copy is replaced */ if (talloc_reference(ldb, global_schema) == NULL) { return LDB_ERR_OPERATIONS_ERROR; diff --git a/source4/setup/provision_init.ldif b/source4/setup/provision_init.ldif index 65a12f1afa..a6c591dd51 100644 --- a/source4/setup/provision_init.ldif +++ b/source4/setup/provision_init.ldif @@ -1,3 +1,8 @@ +#These attributes are only used as far as the bootstrapping of the +# schema. After that, the attributes from the schema are used. +# +# Therefore, they must strictly match the schema + dn: @ATTRIBUTES userPrincipalName: CASE_INSENSITIVE servicePrincipalName: CASE_INSENSITIVE @@ -7,6 +12,8 @@ nETBIOSName: CASE_INSENSITIVE cn: CASE_INSENSITIVE dc: CASE_INSENSITIVE name: CASE_INSENSITIVE +lDAPDisplayName: CASE_INSENSITIVE +subClassOf: CASE_INSENSITIVE dn: CASE_INSENSITIVE sAMAccountName: CASE_INSENSITIVE objectClass: CASE_INSENSITIVE |