summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-27 17:04:04 +0300
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>2009-10-16 12:54:14 +0300
commit8631548f1209b21a35398f391ee7ec698cedd874 (patch)
tree95f46b6b0497707a1f12c27e625632888a31f0ab /source4/torture
parent8639ba2237246a1759d7d1c18db6d7ae1662b151 (diff)
downloadsamba-8631548f1209b21a35398f391ee7ec698cedd874.tar.gz
samba-8631548f1209b21a35398f391ee7ec698cedd874.tar.bz2
samba-8631548f1209b21a35398f391ee7ec698cedd874.zip
s4/drs(tort): _drs_ldap_attr_by_oid() implementation
Utility function to be used to fetch Attribute name and DN giving attribute OID
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/dssync.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index b47564cc91..58b43023ca 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -489,6 +489,55 @@ 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;
+}
+
static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx)
{
NTSTATUS status;