wldap32: Move support for modrdn functions to the Unix library.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2021-04-16 09:59:16 +02:00 committed by Alexandre Julliard
parent 512a51825f
commit d48a9495ce
3 changed files with 60 additions and 162 deletions

View File

@ -470,6 +470,20 @@ int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matc
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
int CDECL wrap_ldap_rename( void *ld, const char *dn, const char *newrdn, const char *newparent, int delete,
LDAPControlU **clientctrls, LDAPControlU **serverctrls, ULONG *msg )
{
return ldap_rename( ld, dn ? dn : "", newrdn, newparent, delete, (LDAPControl **)clientctrls,
(LDAPControl **)serverctrls, (int *)msg );
}
int CDECL wrap_ldap_rename_s( void *ld, const char *dn, const char *newrdn, const char *newparent, int delete,
LDAPControlU **clientctrls, LDAPControlU **serverctrls )
{
return ldap_rename_s( ld, dn ? dn : "", newrdn, newparent, delete, (LDAPControl **)clientctrls,
(LDAPControl **)serverctrls );
}
int CDECL wrap_ldap_result( void *ld, int msgid, int all, struct timevalU *timeout, void **result )
{
return ldap_result( ld, msgid, all, (struct timeval *)timeout, (LDAPMessage **)result );
@ -591,6 +605,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_next_entry,
wrap_ldap_next_reference,
wrap_ldap_parse_result,
wrap_ldap_rename,
wrap_ldap_rename_s,
wrap_ldap_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,

View File

@ -135,6 +135,10 @@ extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_reference(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_rename(void *, const char *, const char *, const char *, int, LDAPControlU **,
LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_rename_s(void *, const char *, const char *, const char *, int, LDAPControlU **,
LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_result(void *, int, int, struct timevalU *, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
@ -201,6 +205,9 @@ struct ldap_funcs
void * (CDECL *ldap_next_entry)(void *, void *);
void * (CDECL *ldap_next_reference)(void *, void *);
int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
int (CDECL *ldap_rename)(void *, const char *, const char *, const char *, int, LDAPControlU **, LDAPControlU **,
ULONG *);
int (CDECL *ldap_rename_s)(void *, const char *, const char *, const char *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);

View File

@ -18,58 +18,38 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#ifdef HAVE_LDAP_H
#include <ldap.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h"
#include "winldap_private.h"
#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
#endif
/***********************************************************************
* ldap_modrdnA (WLDAP32.@)
*
* See ldap_modrdnW.
*/
ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, char *dn, char *newdn )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
if (!ld || !newdn) return ~0u;
if (dn) {
dnW = strAtoW( dn );
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
if (dn && !(dnW = strAtoW( dn ))) goto exit;
if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdnW( ld, dnW, newdnW );
exit:
strfreeW( dnW );
strfreeW( newdnW );
#endif
return ret;
}
@ -81,7 +61,7 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
* newdn [I] New DN for the entry.
* newdn [I] New DN for the entry.
*
* RETURNS
* Success: Message ID of the modrdn operation.
@ -92,40 +72,10 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *newdnU = NULL;
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
if (!ld || !newdn) return ~0u;
if (dn) {
dnU = strWtoU( dn );
if (!dnU) goto exit;
}
newdnU = strWtoU( newdn );
if (!newdnU) goto exit;
ret = ldap_rename( ld->ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = msg;
else
ret = ~0u;
exit:
strfreeU( dnU );
strfreeU( newdnU );
#endif
return ret;
return ldap_modrdn2W( ld, dn, newdn, 1 );
}
/***********************************************************************
@ -133,33 +83,23 @@ exit:
*
* See ldap_modrdn2W.
*/
ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, char *dn, char *newdn, int delete )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return ~0u;
if (dn) {
dnW = strAtoW( dn );
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
if (dn && !(dnW = strAtoW( dn ))) goto exit;
if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
exit:
strfreeW( dnW );
strfreeW( newdnW );
#endif
return ret;
}
@ -171,7 +111,7 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
* newdn [I] New DN for the entry.
* newdn [I] New DN for the entry.
* delete [I] Delete old DN?
*
* RETURNS
@ -183,30 +123,21 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL, *newdnU = NULL;
int msg;
ret = WLDAP32_LDAP_NO_MEMORY;
ULONG msg;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return ~0u;
if (dn) {
dnU = strWtoU( dn );
if (!dnU) goto exit;
}
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(newdnU = strWtoU( newdn ))) goto exit;
newdnU = strWtoU( newdn );
if (!newdnU) goto exit;
ret = ldap_rename( ld->ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
if (ret == LDAP_SUCCESS)
ret = ldap_funcs->ldap_rename( ld->ld, dnU, newdnU, NULL, delete, NULL, NULL, &msg );
if (ret == WLDAP32_LDAP_SUCCESS)
ret = msg;
else
ret = ~0u;
@ -214,8 +145,6 @@ ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete
exit:
strfreeU( dnU );
strfreeU( newdnU );
#endif
return ret;
}
@ -224,33 +153,23 @@ exit:
*
* See ldap_modrdn2_sW.
*/
ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, char *dn, char *newdn, int delete )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnW = strAtoW( dn );
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
if (dn && !(dnW = strAtoW( dn ))) goto exit;
if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
exit:
strfreeW( dnW );
strfreeW( newdnW );
#endif
return ret;
}
@ -262,40 +181,30 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
* newdn [I] New DN for the entry.
* newdn [I] New DN for the entry.
* delete [I] Delete old DN?
*
* RETURNS
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL, *newdnU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnU = strWtoU( dn );
if (!dnU) goto exit;
}
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(newdnU = strWtoU( newdn ))) goto exit;
newdnU = strWtoU( newdn );
if (!newdnU) goto exit;
ret = map_error( ldap_rename_s( ld->ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL ));
ret = map_error( ldap_funcs->ldap_rename_s( ld->ld, dnU, newdnU, NULL, delete, NULL, NULL ));
exit:
strfreeU( dnU );
strfreeU( newdnU );
#endif
return ret;
}
@ -304,33 +213,23 @@ exit:
*
* See ldap_modrdn_sW.
*/
ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, char *dn, char *newdn )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnW = strAtoW( dn );
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
if (dn && !(dnW = strAtoW( dn ))) goto exit;
if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn_sW( ld, dnW, newdnW );
exit:
strfreeW( dnW );
strfreeW( newdnW );
#endif
return ret;
}
@ -342,38 +241,14 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
* newdn [I] New DN for the entry.
* newdn [I] New DN for the entry.
*
* RETURNS
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
char *dnU = NULL, *newdnU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) {
dnU = strWtoU( dn );
if (!dnU) goto exit;
}
newdnU = strWtoU( newdn );
if (!newdnU) goto exit;
ret = map_error( ldap_rename_s( ld->ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL ));
exit:
strfreeU( dnU );
strfreeU( newdnU );
#endif
return ret;
return ldap_modrdn2_sW( ld, dn, newdn, 1 );
}