summaryrefslogtreecommitdiff
path: root/source4/torture/ldap/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/ldap/common.c')
-rw-r--r--source4/torture/ldap/common.c29
1 files changed, 25 insertions, 4 deletions
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;