#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
return ret;
}
+ ret = schema_set_attributes(ldb, schema);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
talloc_steal(ldb, schema);
return LDB_SUCCESS;
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;
+#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
cn: CASE_INSENSITIVE
dc: CASE_INSENSITIVE
name: CASE_INSENSITIVE
+lDAPDisplayName: CASE_INSENSITIVE
+subClassOf: CASE_INSENSITIVE
dn: CASE_INSENSITIVE
sAMAccountName: CASE_INSENSITIVE
objectClass: CASE_INSENSITIVE