diff options
author | Matthieu Patou <mat@matws.net> | 2012-04-16 15:22:24 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-04-18 00:07:00 +0200 |
commit | e3fa5d7d2ad8b7c6248a8df4a0841bf974a6b5a1 (patch) | |
tree | 61bc472c6085f69328306ca26ea1b90f195d4ced /source4/dsdb/samdb/ldb_modules | |
parent | 167c6eb61ee6211a63ffd98f9b86fa300472ea96 (diff) | |
download | samba-e3fa5d7d2ad8b7c6248a8df4a0841bf974a6b5a1.tar.gz samba-e3fa5d7d2ad8b7c6248a8df4a0841bf974a6b5a1.tar.bz2 samba-e3fa5d7d2ad8b7c6248a8df4a0841bf974a6b5a1.zip |
s4-schema: Generate some schema related attribute as MS AD is doing if they are not present in ldb requests
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/samldb.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index a676851bce..41751a2c7d 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -619,6 +619,7 @@ static int samldb_fill_object(struct samldb_ctx *ac) case SAMLDB_TYPE_CLASS: { const struct ldb_val *rdn_value, *def_obj_cat_val; + unsigned int v = ldb_msg_find_attr_as_uint(ac->msg, "objectClassCategory", -2); ret = samdb_find_or_add_attribute(ldb, ac->msg, "rdnAttId", "cn"); @@ -695,11 +696,21 @@ static int samldb_fill_object(struct samldb_ctx *ac) * lookup DN was already saved in "ac->dn" */ ret = samldb_add_step(ac, samldb_find_for_defaultObjectCategory); if (ret != LDB_SUCCESS) return ret; + + /* -2 is not a valid objectClassCategory so it means the attribute wasn't present */ + if (v == -2) { + /* Windows 2003 does this*/ + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "objectClassCategory", 0); + if (ret != LDB_SUCCESS) { + return ret; + } + } break; } case SAMLDB_TYPE_ATTRIBUTE: { const struct ldb_val *rdn_value; + struct ldb_message_element *el; rdn_value = ldb_dn_get_rdn_val(ac->msg->dn); if (rdn_value == NULL) { return ldb_operr(ldb); @@ -739,6 +750,38 @@ static int samldb_fill_object(struct samldb_ctx *ac) } } + el = ldb_msg_find_element(ac->msg, "attributeSyntax"); + if (el) { + /* + * No need to scream if there isn't as we have code later on + * that will take care of it. + */ + const struct dsdb_syntax *syntax = find_syntax_map_by_ad_oid((const char *)el->values[0].data); + if (!syntax) { + DEBUG(9, ("Can't find dsdb_syntax object for attributeSyntax %s\n", + (const char *)el->values[0].data)); + } else { + unsigned int v = ldb_msg_find_attr_as_uint(ac->msg, "oMSyntax", 0); + const struct ldb_val *val = ldb_msg_find_ldb_val(ac->msg, "oMObjectClass"); + + if (v == 0) { + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "oMSyntax", syntax->oMSyntax); + if (ret != LDB_SUCCESS) { + return ret; + } + } + if (!val) { + struct ldb_val val2 = ldb_val_dup(ldb, &syntax->oMObjectClass); + if (val2.length > 0) { + ret = ldb_msg_add_value(ac->msg, "oMObjectClass", &val2, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } + } + } + } + } + /* handle msDS-IntID attribute */ ret = samldb_add_handle_msDS_IntId(ac); if (ret != LDB_SUCCESS) return ret; |