2005-08-22 11:17:15 +02:00
|
|
|
/*
|
|
|
|
* WLDAP32 - LDAP support for Wine
|
|
|
|
*
|
|
|
|
* Copyright 2005 Hans Leidekker
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-22 11:17:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
2021-04-19 10:04:54 +02:00
|
|
|
#include "winldap.h"
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2011-09-05 17:23:34 +02:00
|
|
|
#include "wine/debug.h"
|
2021-04-16 09:59:16 +02:00
|
|
|
#include "winldap_private.h"
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdnA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_modrdnW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdnA( LDAP *ld, char *dn, char *newdn )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
WCHAR *dnW = NULL, *newdnW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld || !newdn) return ~0u;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-04-16 09:59:16 +02:00
|
|
|
if (dn && !(dnW = strAtoW( dn ))) goto exit;
|
|
|
|
if (!(newdnW = strAtoW( newdn ))) goto exit;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
ret = ldap_modrdnW( ld, dnW, newdnW );
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnW );
|
|
|
|
free( newdnW );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdnW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Change the RDN of a directory entry (asynchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of the entry to change.
|
2021-04-16 09:59:16 +02:00
|
|
|
* newdn [I] New DN for the entry.
|
2006-05-16 14:37:17 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Message ID of the modrdn operation.
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_result with the message ID to get the result of
|
|
|
|
* the operation. Cancel the operation by calling ldap_abandon
|
|
|
|
* with the message ID.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdnW( LDAP *ld, WCHAR *dn, WCHAR *newdn )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
|
|
|
TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
|
2021-04-16 09:59:16 +02:00
|
|
|
return ldap_modrdn2W( ld, dn, newdn, 1 );
|
2005-08-22 11:17:15 +02:00
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn2A (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_modrdn2W.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn2A( LDAP *ld, char *dn, char *newdn, int delete )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
WCHAR *dnW = NULL, *newdnW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld || !newdn) return ~0u;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-04-16 09:59:16 +02:00
|
|
|
if (dn && !(dnW = strAtoW( dn ))) goto exit;
|
|
|
|
if (!(newdnW = strAtoW( newdn ))) goto exit;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnW );
|
|
|
|
free( newdnW );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn2W (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Change the RDN of a directory entry (asynchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of the entry to change.
|
2021-04-16 09:59:16 +02:00
|
|
|
* newdn [I] New DN for the entry.
|
2006-05-16 14:37:17 +02:00
|
|
|
* delete [I] Delete old DN?
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Message ID of the modrdn operation.
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Call ldap_result with the message ID to get the result of
|
|
|
|
* the operation. Cancel the operation by calling ldap_abandon
|
|
|
|
* with the message ID.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn2W( LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
char *dnU = NULL, *newdnU = NULL;
|
2021-04-16 09:59:16 +02:00
|
|
|
ULONG msg;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
|
|
|
|
|
2009-01-05 12:40:28 +01:00
|
|
|
if (!ld || !newdn) return ~0u;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (dn && !(dnU = strWtoU( dn ))) return LDAP_NO_MEMORY;
|
|
|
|
|
|
|
|
if ((newdnU = strWtoU( newdn )))
|
|
|
|
{
|
|
|
|
struct ldap_rename_params params = { CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL, &msg };
|
|
|
|
ret = LDAP_CALL( ldap_rename, ¶ms );
|
|
|
|
if (ret == LDAP_SUCCESS)
|
|
|
|
ret = msg;
|
|
|
|
else
|
|
|
|
ret = ~0u;
|
|
|
|
free( newdnU );
|
|
|
|
}
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnU );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn2_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_modrdn2_sW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn2_sA( LDAP *ld, char *dn, char *newdn, int delete )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
WCHAR *dnW = NULL, *newdnW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !newdn) return LDAP_PARAM_ERROR;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-04-16 09:59:16 +02:00
|
|
|
if (dn && !(dnW = strAtoW( dn ))) goto exit;
|
|
|
|
if (!(newdnW = strAtoW( newdn ))) goto exit;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnW );
|
|
|
|
free( newdnW );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn2_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Change the RDN of a directory entry (synchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of the entry to change.
|
2021-04-16 09:59:16 +02:00
|
|
|
* newdn [I] New DN for the entry.
|
2006-05-16 14:37:17 +02:00
|
|
|
* delete [I] Delete old DN?
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn2_sW( LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
char *dnU = NULL, *newdnU = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !newdn) return LDAP_PARAM_ERROR;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if (dn && !(dnU = strWtoU( dn ))) return LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-11-04 11:09:04 +01:00
|
|
|
if ((newdnU = strWtoU( newdn )))
|
|
|
|
{
|
|
|
|
struct ldap_rename_s_params params = { CTX(ld), dnU, newdnU, NULL, delete, NULL, NULL };
|
|
|
|
ret = map_error( LDAP_CALL( ldap_rename_s, ¶ms ));
|
|
|
|
free( newdnU );
|
|
|
|
}
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnU );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn_sA (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* See ldap_modrdn_sW.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn_sA( LDAP *ld, char *dn, char *newdn )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG ret = LDAP_NO_MEMORY;
|
2005-08-22 11:17:15 +02:00
|
|
|
WCHAR *dnW = NULL, *newdnW = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
|
|
|
|
|
2021-04-19 10:04:54 +02:00
|
|
|
if (!ld || !newdn) return LDAP_PARAM_ERROR;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
2021-04-16 09:59:16 +02:00
|
|
|
if (dn && !(dnW = strAtoW( dn ))) goto exit;
|
|
|
|
if (!(newdnW = strAtoW( newdn ))) goto exit;
|
2005-08-22 11:17:15 +02:00
|
|
|
|
|
|
|
ret = ldap_modrdn_sW( ld, dnW, newdnW );
|
|
|
|
|
|
|
|
exit:
|
2021-04-19 10:04:52 +02:00
|
|
|
free( dnW );
|
|
|
|
free( newdnW );
|
2005-08-22 11:17:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-05-16 14:37:17 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ldap_modrdn_sW (WLDAP32.@)
|
|
|
|
*
|
|
|
|
* Change the RDN of a directory entry (synchronous operation).
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ld [I] Pointer to an LDAP context.
|
|
|
|
* dn [I] DN of the entry to change.
|
2021-04-16 09:59:16 +02:00
|
|
|
* newdn [I] New DN for the entry.
|
2006-05-16 14:37:17 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: LDAP_SUCCESS
|
|
|
|
* Failure: An LDAP error code.
|
|
|
|
*/
|
2021-04-19 10:04:54 +02:00
|
|
|
ULONG CDECL ldap_modrdn_sW( LDAP *ld, WCHAR *dn, WCHAR *newdn )
|
2005-08-22 11:17:15 +02:00
|
|
|
{
|
|
|
|
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
|
2021-04-16 09:59:16 +02:00
|
|
|
return ldap_modrdn2_sW( ld, dn, newdn, 1 );
|
2005-08-22 11:17:15 +02:00
|
|
|
}
|