From 9dc1e17c353d61a82a5500d1fad787dda8c766c3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 12 Aug 2004 22:25:01 +0000 Subject: r1793: try to bind multiple times as anonimous and user added -D parameter to torture to be able to specify: - user dn - base dn - user secret (This used to be commit 0eaec28f5c511a28764a1d350c2eaaf37272eb62) --- source4/torture/ldap/common.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'source4/torture/ldap/common.c') diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c index 7d8dcbe4da..7a3d8e48be 100644 --- a/source4/torture/ldap/common.c +++ b/source4/torture/ldap/common.c @@ -1,9 +1,30 @@ #include "includes.h" +NTSTATUS torture_ldap_bind(struct ldap_connection *conn, const char *userdn, const char *password) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + struct ldap_message *response; + + if (!conn) { + printf("We need a valid ldap_connection structure and be connected\n"); + return status; + } + + response = ldap_bind_simple(conn, userdn, password); + if (!response || (response->r.BindResponse.response.resultcode != 0)) { + printf("Failed to bind with provided credentials\n"); + /* FIXME: what abut actually implementing an ldap_connection_free() function ? + :-) sss */ + destroy_ldap_message(response); + return status; + } + + return NT_STATUS_OK; +} + /* open a ldap connection to a server */ -/* TODO: Add support to pass over credentials */ NTSTATUS torture_ldap_connection(struct ldap_connection **conn, - const char *url) + const char *url, const char *userdn, const char *password) { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; BOOL ret; @@ -19,9 +40,9 @@ NTSTATUS torture_ldap_connection(struct ldap_connection **conn, return status; } - ret = ldap_setup_connection(*conn, url); + ret = ldap_setup_connection(*conn, url, userdn, password); if (!ret) { - printf("Failed to connect with url [%s]", url); + printf("Failed to connect with url [%s]\n", url); /* FIXME: what abut actually implementing an ldap_connection_free() function ? :-) sss */ return status; -- cgit