summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c24
-rw-r--r--source4/lib/ldb/modules/rdn_name.c27
-rw-r--r--source4/setup/provision.ldif2
3 files changed, 28 insertions, 25 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index f0f44cf4d5..7b82621c8d 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -410,17 +410,6 @@ static struct ldb_message *samldb_fill_group_object(struct ldb_module *module, c
return NULL;
}
- if ((attribute = samldb_find_attribute(msg2, "cn", NULL)) != NULL) {
- if (strcasecmp(rdn->value.data, attribute->values[0].data) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_group_object: Bad Attribute Syntax for CN\n");
- return NULL;
- }
- } else { /* FIXME: remove this if ldb supports natively aliasing between the rdn and the "cn" attribute */
- if ( ldb_msg_add_value(module->ldb, msg2, "cn", &rdn->value)) {
- return NULL;
- }
- }
-
if ((attribute = samldb_find_attribute(msg2, "objectSid", NULL)) == NULL ) {
struct dom_sid *sid = samldb_get_new_sid(module, msg2, msg2->dn);
if (sid == NULL) {
@@ -481,7 +470,7 @@ static struct ldb_message *samldb_fill_user_or_computer_object(struct ldb_module
return NULL;
}
if (strcasecmp(rdn->name, "cn") != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_user_or_computer_object: Bad RDN (%s) for group!\n", rdn->name);
+ ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_user_or_computer_object: Bad RDN (%s) for user/computer!\n", rdn->name);
return NULL;
}
@@ -490,17 +479,6 @@ static struct ldb_message *samldb_fill_user_or_computer_object(struct ldb_module
return NULL;
}
- if ((attribute = samldb_find_attribute(msg2, "cn", NULL)) != NULL) {
- if (strcasecmp(rdn->value.data, attribute->values[0].data) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_group_object: Bad Attribute Syntax for CN\n");
- return NULL;
- }
- } else { /* FIXME: remove this if ldb supports natively aliasing between the rdn and the "cn" attribute */
- if ( ldb_msg_add_value(module->ldb, msg2, "cn", &rdn->value)) {
- return NULL;
- }
- }
-
if ((attribute = samldb_find_attribute(msg2, "objectSid", NULL)) == NULL ) {
struct dom_sid *sid;
sid = samldb_get_new_sid(module, msg2, msg2->dn);
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 6a11ab87fe..89cc49eb3e 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -88,10 +88,12 @@ static struct ldb_dn_component *get_rdn(void *mem_ctx, const char *dn)
/* add_record: add crateTimestamp/modifyTimestamp attributes */
static int rdn_name_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
+ struct private_data *data = (struct private_data *)module->private_data;
+
struct ldb_message *msg2;
struct ldb_message_element *attribute;
struct ldb_dn_component *rdn;
- int ret, i;
+ int i, ret;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
@@ -126,6 +128,29 @@ static int rdn_name_add_record(struct ldb_module *module, const struct ldb_messa
return -1;
}
+ attribute = rdn_name_find_attribute(msg2, rdn->name);
+
+ if (!attribute) {
+ if (ldb_msg_add_value(module->ldb, msg2, rdn->name, &rdn->value) != 0) {
+ return -1;
+ }
+ } else {
+ const struct ldb_attrib_handler *handler
+ = ldb_attrib_handler(module->ldb, rdn->name);
+ for (i=0; i < attribute->num_values; i++) {
+ if (handler->comparison_fn(module->ldb, msg2, &rdn->value, &attribute->values[i]) == 0) {
+ /* overwrite so it matches in case */
+ attribute->values[i] = rdn->value;
+ break;
+ }
+ }
+ if (i == attribute->num_values) {
+ data->error_string = talloc_asprintf(data, "RDN mismatch on %s: %s", msg2->dn, rdn->name);
+ ldb_debug(module->ldb, LDB_DEBUG_FATAL, "%s\n", data->error_string);
+ return -1;
+ }
+ }
+
ret = ldb_next_add_record(module, msg2);
talloc_free(msg2);
diff --git a/source4/setup/provision.ldif b/source4/setup/provision.ldif
index d70d936988..01dbc6366a 100644
--- a/source4/setup/provision.ldif
+++ b/source4/setup/provision.ldif
@@ -713,7 +713,7 @@ objectCategory: CN=Sites-Container,CN=Schema,CN=Configuration,${BASEDN}
dn: CN=${DEFAULTSITE},CN=Sites,CN=Configuration,${BASEDN}
objectClass: top
objectClass: site
-cn: Sites
+cn: ${DEFAULTSITE}
instanceType: 4
uSNCreated: ${USN}
uSNChanged: ${USN}