Commit 93a2556f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wldap32: Don't call ldap_connect() when a connection has already been established.

parent 3bdf2ad6
...@@ -256,12 +256,10 @@ ULONG CDECL WLDAP32_ldap_connect( LDAP *ld, struct l_timeval *timeout ) ...@@ -256,12 +256,10 @@ ULONG CDECL WLDAP32_ldap_connect( LDAP *ld, struct l_timeval *timeout )
TRACE( "(%p, %p)\n", ld, timeout ); TRACE( "(%p, %p)\n", ld, timeout );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR; if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (CONNECTED(ld)) return WLDAP32_LDAP_SUCCESS;
if (timeout && (timeout->tv_sec || timeout->tv_usec)) if (timeout && (timeout->tv_sec || timeout->tv_usec)) FIXME( "ignoring timeout\n" );
FIXME( "ignoring timeout\n" ); if ((ret = ldap_connect( CTX(ld) ))) return map_error( ret );
if ((ret = ldap_connect( CTX(ld) )))
return map_error( ret );
if (cert_callback) if (cert_callback)
{ {
...@@ -285,6 +283,7 @@ ULONG CDECL WLDAP32_ldap_connect( LDAP *ld, struct l_timeval *timeout ) ...@@ -285,6 +283,7 @@ ULONG CDECL WLDAP32_ldap_connect( LDAP *ld, struct l_timeval *timeout )
} }
} }
CONNECTED(ld) = TRUE;
return WLDAP32_LDAP_SUCCESS; return WLDAP32_LDAP_SUCCESS;
} }
...@@ -456,9 +455,8 @@ ULONG CDECL ldap_start_tls_sW( LDAP *ld, ULONG *retval, LDAPMessage **result, LD ...@@ -456,9 +455,8 @@ ULONG CDECL ldap_start_tls_sW( LDAP *ld, ULONG *retval, LDAPMessage **result, LD
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit; if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else else
{ {
if (CONNECTED(ld)) return WLDAP32_LDAP_LOCAL_ERROR;
ret = map_error( ldap_start_tls_s( CTX(ld), serverctrlsU, clientctrlsU ) ); ret = map_error( ldap_start_tls_s( CTX(ld), serverctrlsU, clientctrlsU ) );
if (!ret && WLDAP32_ldap_connect( ld, NULL ) != WLDAP32_LDAP_SUCCESS)
ret = WLDAP32_LDAP_LOCAL_ERROR;
} }
exit: exit:
......
...@@ -194,16 +194,17 @@ typedef struct WLDAP32_berelement ...@@ -194,16 +194,17 @@ typedef struct WLDAP32_berelement
char *opaque; char *opaque;
} WLDAP32_BerElement; } WLDAP32_BerElement;
typedef struct ldap struct ld_sb
{ {
struct UINT_PTR sb_sd;
{ UCHAR Reserved1[41];
UINT_PTR sb_sd; ULONG_PTR sb_naddr;
UCHAR Reserved1[41]; UCHAR Reserved2[24];
ULONG_PTR sb_naddr; };
UCHAR Reserved2[24];
} ld_sb;
typedef struct ldap
{
struct ld_sb ld_sb;
char *ld_host; char *ld_host;
ULONG ld_version; ULONG ld_version;
UCHAR ld_lberoptions; UCHAR ld_lberoptions;
...@@ -221,6 +222,25 @@ typedef struct ldap ...@@ -221,6 +222,25 @@ typedef struct ldap
ULONG ld_options; ULONG ld_options;
} LDAP, *PLDAP; } LDAP, *PLDAP;
typedef BOOLEAN (CDECL VERIFYSERVERCERT)(LDAP *, const CERT_CONTEXT **);
struct private_data
{
LDAP *ctx;
struct berval **server_ctrls;
VERIFYSERVERCERT *cert_callback;
BOOL connected;
};
C_ASSERT(sizeof(struct private_data) < FIELD_OFFSET(struct ld_sb, sb_naddr) - FIELD_OFFSET(struct ld_sb, Reserved1));
#define CTX(ld) (((struct private_data *)ld->ld_sb.Reserved1)->ctx)
#define SERVER_CTRLS(ld) (((struct private_data *)ld->ld_sb.Reserved1)->server_ctrls)
#define CERT_CALLBACK(ld) (((struct private_data *)ld->ld_sb.Reserved1)->cert_callback)
#define CONNECTED(ld) (((struct private_data *)ld->ld_sb.Reserved1)->connected)
#define MSG(entry) (entry->Request)
#define BER(ber) ((BerElement *)((ber)->opaque))
typedef struct l_timeval typedef struct l_timeval
{ {
LONG tv_sec; LONG tv_sec;
...@@ -366,21 +386,6 @@ typedef struct ldapsearch ...@@ -366,21 +386,6 @@ typedef struct ldapsearch
struct WLDAP32_berval *cookie; struct WLDAP32_berval *cookie;
} LDAPSearch; } LDAPSearch;
typedef BOOLEAN (CDECL VERIFYSERVERCERT)(LDAP*,const CERT_CONTEXT**);
struct private_data
{
LDAP *ctx;
struct berval **server_ctrls;
VERIFYSERVERCERT *cert_callback;
};
#define CTX(ld) (((struct private_data *)ld->Reserved3)->ctx)
#define SERVER_CTRLS(ld) (((struct private_data *)ld->Reserved3)->server_ctrls)
#define CERT_CALLBACK(ld) (((struct private_data *)ld->Reserved3)->cert_callback)
#define MSG(entry) (entry->Request)
#define BER(ber) ((BerElement *)((ber)->opaque))
void CDECL WLDAP32_ber_bvecfree( BERVAL ** ); void CDECL WLDAP32_ber_bvecfree( BERVAL ** );
void CDECL WLDAP32_ber_bvfree( BERVAL * ); void CDECL WLDAP32_ber_bvfree( BERVAL * );
void CDECL WLDAP32_ber_free( WLDAP32_BerElement *, int ); void CDECL WLDAP32_ber_free( WLDAP32_BerElement *, int );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment