Commit d48a9495 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

parent 512a5182
...@@ -470,6 +470,20 @@ int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matc ...@@ -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 ); 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 ) 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 ); return ldap_result( ld, msgid, all, (struct timeval *)timeout, (LDAPMessage **)result );
...@@ -591,6 +605,8 @@ static const struct ldap_funcs funcs = ...@@ -591,6 +605,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_next_entry, wrap_ldap_next_entry,
wrap_ldap_next_reference, wrap_ldap_next_reference,
wrap_ldap_parse_result, wrap_ldap_parse_result,
wrap_ldap_rename,
wrap_ldap_rename_s,
wrap_ldap_result, wrap_ldap_result,
wrap_ldap_sasl_bind, wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s, wrap_ldap_sasl_bind_s,
......
...@@ -135,6 +135,10 @@ extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN; ...@@ -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 void * CDECL wrap_ldap_next_reference(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN; 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_result(void *, int, int, struct timevalU *, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **, extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN; LDAPControlU **, int *) DECLSPEC_HIDDEN;
...@@ -201,6 +205,9 @@ struct ldap_funcs ...@@ -201,6 +205,9 @@ struct ldap_funcs
void * (CDECL *ldap_next_entry)(void *, void *); void * (CDECL *ldap_next_entry)(void *, void *);
void * (CDECL *ldap_next_reference)(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_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_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **, int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *); int *);
......
...@@ -18,58 +18,38 @@ ...@@ -18,58 +18,38 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h"
#include "wine/port.h"
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_LDAP_H
#include <ldap.h>
#endif
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h" #include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "winldap_private.h"
#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32); WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
#endif
/*********************************************************************** /***********************************************************************
* ldap_modrdnA (WLDAP32.@) * ldap_modrdnA (WLDAP32.@)
* *
* See ldap_modrdnW. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
WCHAR *dnW = NULL, *newdnW = NULL; WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) ); TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
if (!ld || !newdn) return ~0u; if (!ld || !newdn) return ~0u;
if (dn) { if (dn && !(dnW = strAtoW( dn ))) goto exit;
dnW = strAtoW( dn ); if (!(newdnW = strAtoW( newdn ))) goto exit;
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
ret = ldap_modrdnW( ld, dnW, newdnW ); ret = ldap_modrdnW( ld, dnW, newdnW );
exit: exit:
strfreeW( dnW ); strfreeW( dnW );
strfreeW( newdnW ); strfreeW( newdnW );
#endif
return ret; return ret;
} }
...@@ -81,7 +61,7 @@ exit: ...@@ -81,7 +61,7 @@ exit:
* PARAMS * PARAMS
* ld [I] Pointer to an LDAP context. * ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change. * dn [I] DN of the entry to change.
* newdn [I] New DN for the entry. * newdn [I] New DN for the entry.
* *
* RETURNS * RETURNS
* Success: Message ID of the modrdn operation. * Success: Message ID of the modrdn operation.
...@@ -92,40 +72,10 @@ exit: ...@@ -92,40 +72,10 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon * the operation. Cancel the operation by calling ldap_abandon
* with the message ID. * 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) ); TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
return ldap_modrdn2W( ld, dn, newdn, 1 );
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;
} }
/*********************************************************************** /***********************************************************************
...@@ -133,33 +83,23 @@ exit: ...@@ -133,33 +83,23 @@ exit:
* *
* See ldap_modrdn2W. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
WCHAR *dnW = NULL, *newdnW = NULL; WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete ); TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return ~0u; if (!ld || !newdn) return ~0u;
if (dn) { if (dn && !(dnW = strAtoW( dn ))) goto exit;
dnW = strAtoW( dn ); if (!(newdnW = strAtoW( newdn ))) goto exit;
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
ret = ldap_modrdn2W( ld, dnW, newdnW, delete ); ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
exit: exit:
strfreeW( dnW ); strfreeW( dnW );
strfreeW( newdnW ); strfreeW( newdnW );
#endif
return ret; return ret;
} }
...@@ -171,7 +111,7 @@ exit: ...@@ -171,7 +111,7 @@ exit:
* PARAMS * PARAMS
* ld [I] Pointer to an LDAP context. * ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change. * 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? * delete [I] Delete old DN?
* *
* RETURNS * RETURNS
...@@ -183,30 +123,21 @@ exit: ...@@ -183,30 +123,21 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon * the operation. Cancel the operation by calling ldap_abandon
* with the message ID. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
char *dnU = NULL, *newdnU = NULL; char *dnU = NULL, *newdnU = NULL;
int msg; ULONG msg;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete ); TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return ~0u; if (!ld || !newdn) return ~0u;
if (dn) { if (dn && !(dnU = strWtoU( dn ))) goto exit;
dnU = strWtoU( dn ); if (!(newdnU = strWtoU( newdn ))) goto exit;
if (!dnU) goto exit;
}
newdnU = strWtoU( newdn );
if (!newdnU) goto exit;
ret = ldap_rename( ld->ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg ); ret = ldap_funcs->ldap_rename( ld->ld, dnU, newdnU, NULL, delete, NULL, NULL, &msg );
if (ret == WLDAP32_LDAP_SUCCESS)
if (ret == LDAP_SUCCESS)
ret = msg; ret = msg;
else else
ret = ~0u; ret = ~0u;
...@@ -214,8 +145,6 @@ ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete ...@@ -214,8 +145,6 @@ ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete
exit: exit:
strfreeU( dnU ); strfreeU( dnU );
strfreeU( newdnU ); strfreeU( newdnU );
#endif
return ret; return ret;
} }
...@@ -224,33 +153,23 @@ exit: ...@@ -224,33 +153,23 @@ exit:
* *
* See ldap_modrdn2_sW. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
WCHAR *dnW = NULL, *newdnW = NULL; WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete ); TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR; if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) { if (dn && !(dnW = strAtoW( dn ))) goto exit;
dnW = strAtoW( dn ); if (!(newdnW = strAtoW( newdn ))) goto exit;
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete ); ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
exit: exit:
strfreeW( dnW ); strfreeW( dnW );
strfreeW( newdnW ); strfreeW( newdnW );
#endif
return ret; return ret;
} }
...@@ -262,40 +181,30 @@ exit: ...@@ -262,40 +181,30 @@ exit:
* PARAMS * PARAMS
* ld [I] Pointer to an LDAP context. * ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change. * 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? * delete [I] Delete old DN?
* *
* RETURNS * RETURNS
* Success: LDAP_SUCCESS * Success: LDAP_SUCCESS
* Failure: An LDAP error code. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
char *dnU = NULL, *newdnU = NULL; char *dnU = NULL, *newdnU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete ); TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR; if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) { if (dn && !(dnU = strWtoU( dn ))) goto exit;
dnU = strWtoU( dn ); if (!(newdnU = strWtoU( newdn ))) goto exit;
if (!dnU) 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: exit:
strfreeU( dnU ); strfreeU( dnU );
strfreeU( newdnU ); strfreeU( newdnU );
#endif
return ret; return ret;
} }
...@@ -304,33 +213,23 @@ exit: ...@@ -304,33 +213,23 @@ exit:
* *
* See ldap_modrdn_sW. * 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; ULONG ret = WLDAP32_LDAP_NO_MEMORY;
#ifdef HAVE_LDAP
WCHAR *dnW = NULL, *newdnW = NULL; WCHAR *dnW = NULL, *newdnW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn ); TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR; if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
if (dn) { if (dn && !(dnW = strAtoW( dn ))) goto exit;
dnW = strAtoW( dn ); if (!(newdnW = strAtoW( newdn ))) goto exit;
if (!dnW) goto exit;
}
newdnW = strAtoW( newdn );
if (!newdnW) goto exit;
ret = ldap_modrdn_sW( ld, dnW, newdnW ); ret = ldap_modrdn_sW( ld, dnW, newdnW );
exit: exit:
strfreeW( dnW ); strfreeW( dnW );
strfreeW( newdnW ); strfreeW( newdnW );
#endif
return ret; return ret;
} }
...@@ -342,38 +241,14 @@ exit: ...@@ -342,38 +241,14 @@ exit:
* PARAMS * PARAMS
* ld [I] Pointer to an LDAP context. * ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change. * dn [I] DN of the entry to change.
* newdn [I] New DN for the entry. * newdn [I] New DN for the entry.
* *
* RETURNS * RETURNS
* Success: LDAP_SUCCESS * Success: LDAP_SUCCESS
* Failure: An LDAP error code. * 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 ); TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
return ldap_modrdn2_sW( ld, dn, newdn, 1 );
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;
} }
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