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 )
TRACE( "(%p, %p)\n", ld, timeout );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (CONNECTED(ld)) return WLDAP32_LDAP_SUCCESS;
if (timeout && (timeout->tv_sec || timeout->tv_usec))
FIXME( "ignoring timeout\n" );
if ((ret = ldap_connect( CTX(ld) )))
return map_error( ret );
if (timeout && (timeout->tv_sec || timeout->tv_usec)) FIXME( "ignoring timeout\n" );
if ((ret = ldap_connect( CTX(ld) ))) return map_error( ret );
if (cert_callback)
{
......@@ -285,6 +283,7 @@ ULONG CDECL WLDAP32_ldap_connect( LDAP *ld, struct l_timeval *timeout )
}
}
CONNECTED(ld) = TRUE;
return WLDAP32_LDAP_SUCCESS;
}
......@@ -456,9 +455,8 @@ ULONG CDECL ldap_start_tls_sW( LDAP *ld, ULONG *retval, LDAPMessage **result, LD
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
{
if (CONNECTED(ld)) return WLDAP32_LDAP_LOCAL_ERROR;
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:
......
......@@ -194,16 +194,17 @@ typedef struct WLDAP32_berelement
char *opaque;
} WLDAP32_BerElement;
typedef struct ldap
struct ld_sb
{
struct
{
UINT_PTR sb_sd;
UCHAR Reserved1[41];
ULONG_PTR sb_naddr;
UCHAR Reserved2[24];
} ld_sb;
UINT_PTR sb_sd;
UCHAR Reserved1[41];
ULONG_PTR sb_naddr;
UCHAR Reserved2[24];
};
typedef struct ldap
{
struct ld_sb ld_sb;
char *ld_host;
ULONG ld_version;
UCHAR ld_lberoptions;
......@@ -221,6 +222,25 @@ typedef struct ldap
ULONG ld_options;
} 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
{
LONG tv_sec;
......@@ -366,21 +386,6 @@ typedef struct ldapsearch
struct WLDAP32_berval *cookie;
} 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_bvfree( BERVAL * );
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