diff options
author | Simo Sorce <idra@samba.org> | 2004-08-12 22:25:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:57:57 -0500 |
commit | 9dc1e17c353d61a82a5500d1fad787dda8c766c3 (patch) | |
tree | 9939bb41d5c92ee77c6da55c06feebe2060f0b4f /source4/torture/ldap/common.c | |
parent | 16c52f7a0786a2583c32fb44ee12ff4f1863f355 (diff) | |
download | samba-9dc1e17c353d61a82a5500d1fad787dda8c766c3.tar.gz samba-9dc1e17c353d61a82a5500d1fad787dda8c766c3.tar.bz2 samba-9dc1e17c353d61a82a5500d1fad787dda8c766c3.zip |
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)
Diffstat (limited to 'source4/torture/ldap/common.c')
-rw-r--r-- | source4/torture/ldap/common.c | 29 |
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; |