summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/dssync.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/rpc/dssync.c')
-rw-r--r--source4/torture/rpc/dssync.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index b47564cc91..a9341d569b 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -36,6 +36,9 @@
#include "auth/gensec/gensec.h"
#include "param/param.h"
#include "dsdb/samdb/samdb.h"
+#include "torture/rpc/rpc.h"
+#include "torture/drs/proto.h"
+
struct DsSyncBindInfo {
struct dcerpc_pipe *pipe;
@@ -489,6 +492,98 @@ static void test_analyse_objects(struct torture_context *tctx,
}
}
+/**
+ * Fetch LDAP attribute name and DN by supplied OID
+ */
+static bool _drs_ldap_attr_by_oid(struct torture_context *tctx,
+ struct DsSyncTest *ctx,
+ const char *oid,
+ const char **attr_dn,
+ const char **attr_name)
+{
+ NTSTATUS status;
+ const char *config_dn;
+ const char *expression;
+ struct ldap_message **res_msg;
+ struct ldap_SearchResEntry *search_res;
+ TALLOC_CTX *tmp_ctx = NULL;
+ const char *search_attrs[] = {"lDAPDisplayName", NULL};
+
+ tmp_ctx = talloc_new(ctx);
+
+ config_dn = talloc_asprintf(tmp_ctx, "CN=Schema,CN=Configuration,%s", ctx->domain_dn);
+ expression = talloc_asprintf(tmp_ctx, "(attributeID=%s)", oid);
+
+ status = ildap_search(ctx->admin.ldap.conn,
+ config_dn, LDAP_SEARCH_SCOPE_SUB,
+ expression, search_attrs, false,
+ NULL, NULL, &res_msg);
+ torture_assert_ntstatus_ok(tctx, status, "LDAP search request failed");
+ torture_assert(tctx,
+ ildap_count_entries(ctx->admin.ldap.conn, res_msg) == 1,
+ talloc_asprintf(tmp_ctx, "Failed to find attribute with OID=%s", oid));
+
+ search_res = &res_msg[0]->r.SearchResultEntry;
+ torture_assert(tctx, search_res->num_attributes > 0, "No attributes returned!")
+ torture_assert(tctx, strequal(search_attrs[0], search_res->attributes[0].name),
+ "Requested attributes for attribute class not returned");
+
+ if (attr_dn) {
+ *attr_dn = search_res->dn;
+ }
+
+ if (attr_name) {
+ *attr_name = (const char *)search_res->attributes[0].values[0].data;
+ }
+
+ talloc_free(tmp_ctx);
+
+ return true;
+}
+
+/**
+ * Make Attribute OID and verify such Attribute exists in schema
+ */
+static bool _drs_util_verify_attids(struct torture_context *tctx,
+ struct DsSyncTest *ctx,
+ struct drsuapi_DsReplicaOIDMapping_Ctr *prefix_map,
+ struct drsuapi_DsReplicaObjectListItemEx *cur)
+{
+ uint32_t i;
+
+ DEBUG(1,("drs_test_verify_attids:\n"));
+
+ for (; cur; cur = cur->next_object) {
+ const char *attr_dn = NULL;
+ const char *attr_name = NULL;
+ struct drsuapi_DsReplicaObject *obj = &cur->object;
+
+ DEBUG(1,("%3s %-10s: %s\n", "", "object_dn", obj->identifier->dn));
+
+ for (i = 0; i < obj->attribute_ctr.num_attributes; i++) {
+ int map_idx;
+ const char *oid = NULL;
+ struct drsuapi_DsReplicaAttribute *attr;
+
+ attr = &obj->attribute_ctr.attributes[i];
+ if (!drs_util_oid_from_attid(tctx, prefix_map, attr->attid, &oid, &map_idx)) {
+ return false;
+ }
+
+ if (!_drs_ldap_attr_by_oid(tctx, ctx, oid, &attr_dn, &attr_name)) {
+ return false;
+ }
+
+ DEBUG(1,("%7s attr[%2d]: %-22s {map_idx=%2d; attid=0x%06x; ldap_name=%-26s; idl_name=%s}\n", "",
+ i, oid, map_idx, attr->attid, attr_name,
+ drs_util_DsAttributeId_to_string(attr->attid)));
+ }
+ }
+
+ return true;
+}
+
+
static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx)
{
NTSTATUS status;
@@ -670,6 +765,8 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx)
(long long)ctr1->new_highwatermark.tmp_highest_usn,
(long long)ctr1->new_highwatermark.highest_usn));
+ _drs_util_verify_attids(tctx, ctx, &ctr1->mapping_ctr, ctr1->first_object);
+
test_analyse_objects(tctx, ctx, &gensec_skey, ctr1->first_object);
if (ctr1->more_data) {
@@ -700,6 +797,8 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx)
(long long)ctr6->new_highwatermark.tmp_highest_usn,
(long long)ctr6->new_highwatermark.highest_usn));
+ _drs_util_verify_attids(tctx, ctx, &ctr6->mapping_ctr, ctr6->first_object);
+
test_analyse_objects(tctx, ctx, &gensec_skey, ctr6->first_object);
if (ctr6->more_data) {