2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
28 #include "winldap_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
32 /***********************************************************************
33 * ldap_rename_extA (WLDAP32.@)
35 * See ldap_rename_extW.
37 ULONG CDECL
ldap_rename_extA( LDAP
*ld
, char *dn
, char *newrdn
, char *newparent
, int delete,
38 LDAPControlA
**serverctrls
, LDAPControlA
**clientctrls
, ULONG
*message
)
40 ULONG ret
= LDAP_NO_MEMORY
;
41 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
42 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
44 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_a(dn
), debugstr_a(newrdn
), debugstr_a(newparent
),
45 delete, serverctrls
, clientctrls
, message
);
47 if (!ld
|| !message
) return LDAP_PARAM_ERROR
;
49 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
50 if (newrdn
&& !(newrdnW
= strAtoW( newrdn
))) goto exit
;
51 if (newparent
&& !(newparentW
= strAtoW( newparent
))) goto exit
;
52 if (serverctrls
&& !(serverctrlsW
= controlarrayAtoW( serverctrls
))) goto exit
;
53 if (clientctrls
&& !(clientctrlsW
= controlarrayAtoW( clientctrls
))) goto exit
;
55 ret
= ldap_rename_extW( ld
, dnW
, newrdnW
, newparentW
, delete, serverctrlsW
, clientctrlsW
, message
);
61 controlarrayfreeW( serverctrlsW
);
62 controlarrayfreeW( clientctrlsW
);
66 /***********************************************************************
67 * ldap_rename_extW (WLDAP32.@)
69 * Change the DN of a directory entry (asynchronous operation).
72 * ld [I] Pointer to an LDAP context.
73 * dn [I] DN of the entry to change.
74 * newrdn [I] New RDN for the entry.
75 * newparent [I] New parent for the entry.
76 * delete [I] Delete old RDN?
77 * serverctrls [I] Array of LDAP server controls.
78 * clientctrls [I] Array of LDAP client controls.
79 * message [O] Message ID of the operation.
82 * Success: LDAP_SUCCESS
83 * Failure: An LDAP error code.
86 * Call ldap_result with the message ID to get the result of
87 * the operation. Cancel the operation by calling ldap_abandon
88 * with the message ID.
90 ULONG CDECL
ldap_rename_extW( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newrdn
, WCHAR
*newparent
, int delete,
91 LDAPControlW
**serverctrls
, LDAPControlW
**clientctrls
, ULONG
*message
)
93 ULONG ret
= LDAP_NO_MEMORY
;
94 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
95 LDAPControlU
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
97 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_w(dn
), debugstr_w(newrdn
), debugstr_w(newparent
),
98 delete, serverctrls
, clientctrls
, message
);
100 if (!ld
|| !message
) return LDAP_PARAM_ERROR
;
102 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
103 if (newrdn
&& !(newrdnU
= strWtoU( newrdn
))) goto exit
;
104 if (newparent
&& !(newparentU
= strWtoU( newparent
))) goto exit
;
105 if (serverctrls
&& !(serverctrlsU
= controlarrayWtoU( serverctrls
))) goto exit
;
106 if (clientctrls
&& !(clientctrlsU
= controlarrayWtoU( clientctrls
))) goto exit
;
108 ret
= map_error( ldap_funcs
->fn_ldap_rename( CTX(ld
), dnU
, newrdnU
, newparentU
, delete, serverctrlsU
, clientctrlsU
,
114 controlarrayfreeU( serverctrlsU
);
115 controlarrayfreeU( clientctrlsU
);
119 /***********************************************************************
120 * ldap_rename_ext_sA (WLDAP32.@)
122 * See ldap_rename_ext_sW.
124 ULONG CDECL
ldap_rename_ext_sA( LDAP
*ld
, char *dn
, char *newrdn
, char *newparent
, int delete,
125 LDAPControlA
**serverctrls
, LDAPControlA
**clientctrls
)
127 ULONG ret
= LDAP_NO_MEMORY
;
128 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
129 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
131 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_a(dn
), debugstr_a(newrdn
), debugstr_a(newparent
),
132 delete, serverctrls
, clientctrls
);
134 if (!ld
) return LDAP_PARAM_ERROR
;
136 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
137 if (newrdn
&& !(newrdnW
= strAtoW( newrdn
))) goto exit
;
138 if (newparent
&& !(newparentW
= strAtoW( newparent
))) goto exit
;
139 if (serverctrls
&& !(serverctrlsW
= controlarrayAtoW( serverctrls
))) goto exit
;
140 if (clientctrls
&& !(clientctrlsW
= controlarrayAtoW( clientctrls
))) goto exit
;
142 ret
= ldap_rename_ext_sW( ld
, dnW
, newrdnW
, newparentW
, delete, serverctrlsW
, clientctrlsW
);
148 controlarrayfreeW( serverctrlsW
);
149 controlarrayfreeW( clientctrlsW
);
152 /***********************************************************************
153 * ldap_rename_ext_sW (WLDAP32.@)
155 * Change the DN of a directory entry (synchronous operation).
158 * ld [I] Pointer to an LDAP context.
159 * dn [I] DN of the entry to change.
160 * newrdn [I] New RDN for the entry.
161 * newparent [I] New parent for the entry.
162 * delete [I] Delete old RDN?
163 * serverctrls [I] Array of LDAP server controls.
164 * clientctrls [I] Array of LDAP client controls.
167 * Success: LDAP_SUCCESS
168 * Failure: An LDAP error code.
170 ULONG CDECL
ldap_rename_ext_sW( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newrdn
, WCHAR
*newparent
, int delete,
171 LDAPControlW
**serverctrls
, LDAPControlW
**clientctrls
)
173 ULONG ret
= LDAP_PARAM_ERROR
;
174 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
175 LDAPControlU
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
177 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_w(dn
), debugstr_w(newrdn
), debugstr_w(newparent
),
178 delete, serverctrls
, clientctrls
);
180 if (!ld
) return LDAP_PARAM_ERROR
;
182 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
183 if (newrdn
&& !(newrdnU
= strWtoU( newrdn
))) goto exit
;
184 if (newparent
&& !(newparentU
= strWtoU( newparent
))) goto exit
;
185 if (serverctrls
&& !(serverctrlsU
= controlarrayWtoU( serverctrls
))) goto exit
;
186 if (clientctrls
&& !(clientctrlsU
= controlarrayWtoU( clientctrls
))) goto exit
;
188 ret
= map_error( ldap_funcs
->fn_ldap_rename_s( CTX(ld
), dnU
, newrdnU
, newparentU
, delete, serverctrlsU
,
194 controlarrayfreeU( serverctrlsU
);
195 controlarrayfreeU( clientctrlsU
);