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
22 #include "wine/port.h"
33 #include "winldap_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
39 /***********************************************************************
40 * ldap_rename_extA (WLDAP32.@)
42 * See ldap_rename_extW.
44 ULONG CDECL
ldap_rename_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
45 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
46 PLDAPControlA
*clientctrls
, ULONG
*message
)
48 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
50 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
51 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
53 ret
= WLDAP32_LDAP_NO_MEMORY
;
55 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_a(dn
),
56 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
57 serverctrls
, clientctrls
, message
);
59 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
66 newrdnW
= strAtoW( newrdn
);
67 if (!newrdnW
) goto exit
;
70 newparentW
= strAtoW( newparent
);
71 if (!newparentW
) goto exit
;
74 serverctrlsW
= controlarrayAtoW( serverctrls
);
75 if (!serverctrlsW
) goto exit
;
78 clientctrlsW
= controlarrayAtoW( clientctrls
);
79 if (!clientctrlsW
) goto exit
;
82 ret
= ldap_rename_extW( ld
, dnW
, newrdnW
, newparentW
, delete,
83 serverctrlsW
, clientctrlsW
, message
);
88 strfreeW( newparentW
);
89 controlarrayfreeW( serverctrlsW
);
90 controlarrayfreeW( clientctrlsW
);
96 /***********************************************************************
97 * ldap_rename_extW (WLDAP32.@)
99 * Change the DN of a directory entry (asynchronous operation).
102 * ld [I] Pointer to an LDAP context.
103 * dn [I] DN of the entry to change.
104 * newrdn [I] New RDN for the entry.
105 * newparent [I] New parent for the entry.
106 * delete [I] Delete old RDN?
107 * serverctrls [I] Array of LDAP server controls.
108 * clientctrls [I] Array of LDAP client controls.
109 * message [O] Message ID of the operation.
112 * Success: LDAP_SUCCESS
113 * Failure: An LDAP error code.
116 * Call ldap_result with the message ID to get the result of
117 * the operation. Cancel the operation by calling ldap_abandon
118 * with the message ID.
120 ULONG CDECL
ldap_rename_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
121 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
122 PLDAPControlW
*clientctrls
, ULONG
*message
)
124 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
126 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
127 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
129 ret
= WLDAP32_LDAP_NO_MEMORY
;
131 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_w(dn
),
132 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
133 serverctrls
, clientctrls
, message
);
135 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
142 newrdnU
= strWtoU( newrdn
);
143 if (!newrdnU
) goto exit
;
146 newparentU
= strWtoU( newparent
);
147 if (!newparentU
) goto exit
;
150 serverctrlsU
= controlarrayWtoU( serverctrls
);
151 if (!serverctrlsU
) goto exit
;
154 clientctrlsU
= controlarrayWtoU( clientctrls
);
155 if (!clientctrlsU
) goto exit
;
158 ret
= map_error( ldap_rename( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
159 delete, serverctrlsU
, clientctrlsU
, (int *)message
));
164 strfreeU( newparentU
);
165 controlarrayfreeU( serverctrlsU
);
166 controlarrayfreeU( clientctrlsU
);
172 /***********************************************************************
173 * ldap_rename_ext_sA (WLDAP32.@)
175 * See ldap_rename_ext_sW.
177 ULONG CDECL
ldap_rename_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
178 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
179 PLDAPControlA
*clientctrls
)
181 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
183 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
184 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
186 ret
= WLDAP32_LDAP_NO_MEMORY
;
188 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_a(dn
),
189 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
190 serverctrls
, clientctrls
);
192 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
199 newrdnW
= strAtoW( newrdn
);
200 if (!newrdnW
) goto exit
;
203 newparentW
= strAtoW( newparent
);
204 if (!newparentW
) goto exit
;
207 serverctrlsW
= controlarrayAtoW( serverctrls
);
208 if (!serverctrlsW
) goto exit
;
211 clientctrlsW
= controlarrayAtoW( clientctrls
);
212 if (!clientctrlsW
) goto exit
;
215 ret
= ldap_rename_ext_sW( ld
, dnW
, newrdnW
, newparentW
, delete,
216 serverctrlsW
, clientctrlsW
);
221 strfreeW( newparentW
);
222 controlarrayfreeW( serverctrlsW
);
223 controlarrayfreeW( clientctrlsW
);
228 /***********************************************************************
229 * ldap_rename_ext_sW (WLDAP32.@)
231 * Change the DN of a directory entry (synchronous operation).
234 * ld [I] Pointer to an LDAP context.
235 * dn [I] DN of the entry to change.
236 * newrdn [I] New RDN for the entry.
237 * newparent [I] New parent for the entry.
238 * delete [I] Delete old RDN?
239 * serverctrls [I] Array of LDAP server controls.
240 * clientctrls [I] Array of LDAP client controls.
243 * Success: LDAP_SUCCESS
244 * Failure: An LDAP error code.
246 ULONG CDECL
ldap_rename_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
247 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
248 PLDAPControlW
*clientctrls
)
250 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
252 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
253 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
255 ret
= WLDAP32_LDAP_NO_MEMORY
;
257 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_w(dn
),
258 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
259 serverctrls
, clientctrls
);
261 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
268 newrdnU
= strWtoU( newrdn
);
269 if (!newrdnU
) goto exit
;
272 newparentU
= strWtoU( newparent
);
273 if (!newparentU
) goto exit
;
276 serverctrlsU
= controlarrayWtoU( serverctrls
);
277 if (!serverctrlsU
) goto exit
;
280 clientctrlsU
= controlarrayWtoU( clientctrls
);
281 if (!clientctrlsU
) goto exit
;
284 ret
= map_error( ldap_rename_s( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
285 delete, serverctrlsU
, clientctrlsU
));
290 strfreeU( newparentU
);
291 controlarrayfreeU( serverctrlsU
);
292 controlarrayfreeU( clientctrlsU
);