Avoid using deprecated openldap functions.

Correct some return values.
This commit is contained in:
Hans Leidekker 2005-11-18 15:05:01 +00:00 committed by Alexandre Julliard
parent a81afd15d8
commit 29c2c75e04
3 changed files with 81 additions and 31 deletions

View File

@ -79,6 +79,7 @@ ULONG ldap_addW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
#ifdef HAVE_LDAP
char *dnU = NULL;
LDAPMod **attrsU = NULL;
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
@ -95,7 +96,12 @@ ULONG ldap_addW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
if (!attrsU) goto exit;
}
ret = ldap_add( ld, dn ? dnU : "", attrs ? attrsU : nullattrs );
ret = ldap_add_ext( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0UL;
exit:
strfreeU( dnU );
@ -119,7 +125,7 @@ ULONG ldap_add_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[],
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), attrs,
serverctrls, clientctrls, message );
if (!ld) return ~0UL;
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnW = strAtoW( dn );
@ -165,8 +171,7 @@ ULONG ldap_add_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), attrs,
serverctrls, clientctrls, message );
if (!ld) return ~0UL;
if (!attrs) return LDAP_PROTOCOL_ERROR;
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnU = strWtoU( dn );
@ -185,7 +190,7 @@ ULONG ldap_add_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
if (!clientctrlsU) goto exit;
}
ret = ldap_add_ext( ld, dn ? dnU : "", attrs? attrsU : nullattrs, serverctrlsU,
ret = ldap_add_ext( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, serverctrlsU,
clientctrlsU, message ? (int *)message : &dummy );
exit:
@ -344,7 +349,7 @@ ULONG ldap_add_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
if (!attrsU) goto exit;
}
ret = ldap_add_s( ld, dn ? dnU : "", attrs ? attrsU : nullattrs );
ret = ldap_add_ext_s( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, NULL, NULL );
exit:
strfreeU( dnU );

View File

@ -77,12 +77,15 @@ ULONG ldap_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *credU = NULL;
struct berval pwd = { 0, NULL };
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%08lx)\n", ld, debugstr_w(dn), cred, method );
if (!ld) return ~0UL;
if (method != LDAP_AUTH_SIMPLE) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnU = strWtoU( dn );
@ -91,9 +94,17 @@ ULONG ldap_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
if (cred) {
credU = strWtoU( cred );
if (!credU) goto exit;
pwd.bv_len = strlen( credU );
pwd.bv_val = credU;
}
ret = ldap_bind( ld, dnU, credU, method );
ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0UL;
exit:
strfreeU( dnU );
@ -139,12 +150,14 @@ ULONG ldap_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *credU = NULL;
struct berval pwd = { 0, NULL };
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%08lx)\n", ld, debugstr_w(dn), cred, method );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (method != LDAP_AUTH_SIMPLE) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnU = strWtoU( dn );
@ -153,9 +166,12 @@ ULONG ldap_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR cred, ULONG method )
if (cred) {
credU = strWtoU( cred );
if (!credU) goto exit;
pwd.bv_len = strlen( credU );
pwd.bv_val = credU;
}
ret = ldap_bind_s( ld, dnU, credU, method );
ret = ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL );
exit:
strfreeU( dnU );
@ -379,6 +395,8 @@ ULONG ldap_simple_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *passwdU = NULL;
struct berval pwd = { 0, NULL };
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
@ -393,9 +411,17 @@ ULONG ldap_simple_bindW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
if (passwd) {
passwdU = strWtoU( passwd );
if (!passwdU) goto exit;
pwd.bv_len = strlen( passwdU );
pwd.bv_val = passwdU;
}
ret = ldap_simple_bind( ld, dnU, passwdU );
ret = ldap_sasl_bind( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0UL;
exit:
strfreeU( dnU );
@ -441,6 +467,7 @@ ULONG ldap_simple_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *passwdU = NULL;
struct berval pwd = { 0, NULL };
ret = WLDAP32_LDAP_NO_MEMORY;
@ -455,9 +482,12 @@ ULONG ldap_simple_bind_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR passwd )
if (passwd) {
passwdU = strWtoU( passwd );
if (!passwdU) goto exit;
pwd.bv_len = strlen( passwdU );
pwd.bv_val = passwdU;
}
ret = ldap_simple_bind_s( ld, dnU, passwdU );
ret = ldap_sasl_bind_s( ld, dnU, LDAP_SASL_SIMPLE, &pwd, NULL, NULL, NULL );
exit:
strfreeU( dnU );
@ -475,7 +505,7 @@ ULONG WLDAP32_ldap_unbind( WLDAP32_LDAP *ld )
TRACE( "(%p)\n", ld );
if (ld)
ret = ldap_unbind( ld );
ret = ldap_unbind_ext( ld, NULL, NULL );
else
ret = WLDAP32_LDAP_PARAM_ERROR;
@ -491,7 +521,7 @@ ULONG WLDAP32_ldap_unbind_s( WLDAP32_LDAP *ld )
TRACE( "(%p)\n", ld );
if (ld)
ret = ldap_unbind_s( ld );
ret = ldap_unbind_ext_s( ld, NULL, NULL );
else
ret = WLDAP32_LDAP_PARAM_ERROR;

View File

@ -46,21 +46,21 @@ ULONG ldap_compareA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value )
#ifdef HAVE_LDAP
WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
ret = ~0UL;
TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(attr),
debugstr_a(value) );
if (!ld) return ~0UL;
if (!ld || !attr) return ~0UL;
if (dn) {
dnW = strAtoW( dn );
if (!dnW) goto exit;
}
if (attr) {
attrW = strAtoW( attr );
if (!attrW) goto exit;
}
attrW = strAtoW( attr );
if (!attrW) goto exit;
if (value) {
valueW = strAtoW( value );
if (!valueW) goto exit;
@ -82,14 +82,15 @@ ULONG ldap_compareW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *attrU = NULL, *valueU = NULL;
struct berval val = { 0, NULL };
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
ret = ~0UL;
TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(attr),
debugstr_w(value) );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!attr) return ~0UL;
if (!ld || !attr) return ~0UL;
if (dn) {
dnU = strWtoU( dn );
@ -102,9 +103,17 @@ ULONG ldap_compareW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
if (value) {
valueU = strWtoU( value );
if (!valueU) goto exit;
val.bv_len = strlen( valueU );
val.bv_val = valueU;
}
ret = ldap_compare( ld, dn ? dnU : "", attrU, value ? valueU : "" );
ret = ldap_compare_ext( ld, dn ? dnU : "", attrU, &val, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0UL;
exit:
strfreeU( dnU );
@ -175,7 +184,7 @@ ULONG ldap_compare_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value,
#ifdef HAVE_LDAP
char *dnU = NULL, *attrU = NULL, *valueU = NULL;
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
struct berval berval;
struct berval val = { 0, NULL };
ret = WLDAP32_LDAP_NO_MEMORY;
@ -198,9 +207,10 @@ ULONG ldap_compare_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value,
if (value) {
valueU = strWtoU( value );
if (!valueU) goto exit;
val.bv_len = strlen( valueU );
val.bv_val = valueU;
}
berval.bv_len = valueU ? strlen( valueU ) : 0;
berval.bv_val = valueU;
}
if (serverctrls) {
serverctrlsU = controlarrayWtoU( serverctrls );
@ -211,7 +221,7 @@ ULONG ldap_compare_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value,
if (!clientctrlsU) goto exit;
}
ret = ldap_compare_ext( ld, dn ? dnU : "", attrU, data ? (struct berval *)data : &berval,
ret = ldap_compare_ext( ld, dn ? dnU : "", attrU, data ? (struct berval *)data : &val,
serverctrlsU, clientctrlsU, (int *)message );
exit:
@ -281,9 +291,9 @@ ULONG ldap_compare_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR valu
{
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
struct berval berval;
char *dnU = NULL, *attrU = NULL, *valueU = NULL;
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
struct berval val = { 0, NULL };
ret = WLDAP32_LDAP_NO_MEMORY;
@ -305,9 +315,10 @@ ULONG ldap_compare_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR valu
if (value) {
valueU = strWtoU( value );
if (!valueU) goto exit;
val.bv_len = strlen( valueU );
val.bv_val = valueU;
}
berval.bv_len = valueU ? strlen( valueU ) : 0;
berval.bv_val = valueU;
}
if (serverctrls) {
serverctrlsU = controlarrayWtoU( serverctrls );
@ -318,7 +329,7 @@ ULONG ldap_compare_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR valu
if (!clientctrlsU) goto exit;
}
ret = ldap_compare_ext_s( ld, dn ? dnU : "", attr ? attrU : "", data ? (struct berval *)data : &berval,
ret = ldap_compare_ext_s( ld, dn ? dnU : "", attr ? attrU : "", data ? (struct berval *)data : &val,
serverctrlsU, clientctrlsU );
exit:
@ -374,6 +385,7 @@ ULONG ldap_compare_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
ULONG ret = LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *attrU = NULL, *valueU = NULL;
struct berval val = { 0, NULL };
ret = WLDAP32_LDAP_NO_MEMORY;
@ -393,9 +405,12 @@ ULONG ldap_compare_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR attr, PWCHAR value )
if (value) {
valueU = strWtoU( value );
if (!valueU) goto exit;
val.bv_len = strlen( valueU );
val.bv_val = valueU;
}
ret = ldap_compare_s( ld, dn ? dnU : "", attr ? attrU : "", value ? valueU : "" );
ret = ldap_compare_ext_s( ld, dn ? dnU : "", attr ? attrU : "", &val, NULL, NULL );
exit:
strfreeU( dnU );