diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-12-28 17:19:29 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-01-02 08:16:54 +1100 |
commit | 38160deac4d6f4a8ae22fcedcf55114bc0372f31 (patch) | |
tree | f89da2284e933256b2fda390e8a9090c6b26f128 | |
parent | 5e52c7149fb6f4e79541cde719f7f014d8954922 (diff) | |
download | samba-38160deac4d6f4a8ae22fcedcf55114bc0372f31.tar.gz samba-38160deac4d6f4a8ae22fcedcf55114bc0372f31.tar.bz2 samba-38160deac4d6f4a8ae22fcedcf55114bc0372f31.zip |
s4-drs: use dsdb linked attribute parse functions
This makes the code considerably more readable
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 27 | ||||
-rw-r--r-- | source4/rpc_server/drsuapi/getncchanges.c | 20 |
2 files changed, 5 insertions, 42 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 3c713ec4d9..baae44a30d 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -3345,9 +3345,7 @@ static int replmd_process_linked_attribute(struct ldb_module *module, const struct dsdb_attribute *attr; struct dsdb_dn *dsdb_dn; uint64_t seq_num = 0; - struct drsuapi_DsReplicaAttribute drs; - struct drsuapi_DsAttributeValue val; - struct ldb_message_element new_el, *old_el; + struct ldb_message_element *old_el; WERROR status; time_t t = time(NULL); struct ldb_result *res; @@ -3358,10 +3356,6 @@ static int replmd_process_linked_attribute(struct ldb_module *module, bool active = (la->flags & DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE)?true:false; const struct GUID *our_invocation_id; - drs.value_ctr.num_values = 1; - drs.value_ctr.values = &val; - val.blob = la->value.blob; - /* linked_attributes[0]: &objs->linked_attributes[i]: struct drsuapi_DsReplicaLinkedAttribute @@ -3462,23 +3456,10 @@ linked_attributes[0]: return ret; } - status = attr->syntax->drsuapi_to_ldb(ldb, schema, attr, &drs, tmp_ctx, &new_el); + status = dsdb_dn_la_from_blob(ldb, attr, schema, tmp_ctx, la->value.blob, &dsdb_dn); if (!W_ERROR_IS_OK(status)) { - ldb_asprintf_errstring(ldb, "Failed to parsed linked attribute blob for %s on %s\n", - old_el->name, ldb_dn_get_linearized(msg->dn)); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (new_el.num_values != 1) { - ldb_asprintf_errstring(ldb, "Failed to find value in linked attribute blob for %s on %s\n", - old_el->name, ldb_dn_get_linearized(msg->dn)); - return LDB_ERR_OPERATIONS_ERROR; - } - - dsdb_dn = dsdb_dn_parse(tmp_ctx, ldb, &new_el.values[0], attr->syntax->ldap_oid); - if (!dsdb_dn) { - ldb_asprintf_errstring(ldb, "Failed to parse DN in linked attribute blob for %s on %s\n", - old_el->name, ldb_dn_get_linearized(msg->dn)); + ldb_asprintf_errstring(ldb, "Failed to parsed linked attribute blob for %s on %s - %s\n", + old_el->name, ldb_dn_get_linearized(msg->dn), win_errstr(status)); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index cf4b637c0c..dc4483c8f8 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -246,10 +246,7 @@ static WERROR get_nc_changes_add_la(TALLOC_CTX *mem_ctx, struct drsuapi_DsReplicaLinkedAttribute *la; bool active; NTSTATUS status; - struct ldb_message_element val_el; - struct ldb_val v; WERROR werr; - struct drsuapi_DsReplicaAttribute drs; (*la_list) = talloc_realloc(mem_ctx, *la_list, struct drsuapi_DsReplicaLinkedAttribute, (*la_count)+1); W_ERROR_HAVE_NO_MEMORY(*la_list); @@ -285,24 +282,9 @@ static WERROR get_nc_changes_add_la(TALLOC_CTX *mem_ctx, return ntstatus_to_werror(status); } - /* we need a message_element with just one value in it */ - v = data_blob_string_const(dsdb_dn_get_extended_linearized(*la_list, dsdb_dn, 1)); - - val_el.name = sa->lDAPDisplayName; - val_el.values = &v; - val_el.num_values = 1; - - werr = sa->syntax->ldb_to_drsuapi(sam_ctx, schema, sa, &val_el, *la_list, &drs); + werr = dsdb_dn_la_to_blob(sam_ctx, sa, schema, *la_list, dsdb_dn, &la->value.blob); W_ERROR_NOT_OK_RETURN(werr); - if (drs.value_ctr.num_values != 1) { - DEBUG(1,(__location__ ": Failed to build DRS blob for linked attribute %s in %s\n", - sa->lDAPDisplayName, ldb_dn_get_linearized(msg->dn))); - return WERR_DS_DRA_INTERNAL_ERROR; - } - - la->value.blob = drs.value_ctr.values[0].blob; - (*la_count)++; return WERR_OK; } |