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
23 #include "wine/port.h"
24 #include "wine/debug.h"
36 #include "winldap_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
41 /***********************************************************************
42 * ldap_modrdnA (WLDAP32.@)
46 ULONG CDECL
ldap_modrdnA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
)
48 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
50 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
52 ret
= WLDAP32_LDAP_NO_MEMORY
;
54 TRACE( "(%p, %s, %s)\n", ld
, debugstr_a(dn
), debugstr_a(newdn
) );
56 if (!ld
|| !newdn
) return ~0UL;
63 newdnW
= strAtoW( newdn
);
64 if (!newdnW
) goto exit
;
66 ret
= ldap_modrdnW( ld
, dnW
, newdnW
);
76 /***********************************************************************
77 * ldap_modrdnW (WLDAP32.@)
79 * Change the RDN of a directory entry (asynchronous operation).
82 * ld [I] Pointer to an LDAP context.
83 * dn [I] DN of the entry to change.
84 * newdn [I] New DN for the entry.
87 * Success: Message ID of the modrdn operation.
88 * Failure: An LDAP error code.
91 * Call ldap_result with the message ID to get the result of
92 * the operation. Cancel the operation by calling ldap_abandon
93 * with the message ID.
95 ULONG CDECL
ldap_modrdnW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
)
97 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
99 char *dnU
= NULL
, *newdnU
= NULL
;
102 ret
= WLDAP32_LDAP_NO_MEMORY
;
104 TRACE( "(%p, %s, %s)\n", ld
, debugstr_w(dn
), debugstr_w(newdn
) );
106 if (!ld
|| !newdn
) return ~0UL;
113 newdnU
= strWtoU( newdn
);
114 if (!newdnU
) goto exit
;
116 ret
= ldap_rename( ld
, dn
? dnU
: "", newdnU
, NULL
, 1, NULL
, NULL
, &msg
);
118 if (ret
== LDAP_SUCCESS
)
131 /***********************************************************************
132 * ldap_modrdn2A (WLDAP32.@)
136 ULONG CDECL
ldap_modrdn2A( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
, INT
delete )
138 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
140 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
142 ret
= WLDAP32_LDAP_NO_MEMORY
;
144 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
146 if (!ld
|| !newdn
) return ~0UL;
153 newdnW
= strAtoW( newdn
);
154 if (!newdnW
) goto exit
;
156 ret
= ldap_modrdn2W( ld
, dnW
, newdnW
, delete );
166 /***********************************************************************
167 * ldap_modrdn2W (WLDAP32.@)
169 * Change the RDN of a directory entry (asynchronous operation).
172 * ld [I] Pointer to an LDAP context.
173 * dn [I] DN of the entry to change.
174 * newdn [I] New DN for the entry.
175 * delete [I] Delete old DN?
178 * Success: Message ID of the modrdn operation.
179 * Failure: An LDAP error code.
182 * Call ldap_result with the message ID to get the result of
183 * the operation. Cancel the operation by calling ldap_abandon
184 * with the message ID.
186 ULONG CDECL
ldap_modrdn2W( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
, INT
delete )
188 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
190 char *dnU
= NULL
, *newdnU
= NULL
;
193 ret
= WLDAP32_LDAP_NO_MEMORY
;
195 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
197 if (!ld
|| !newdn
) return ~0UL;
204 newdnU
= strWtoU( newdn
);
205 if (!newdnU
) goto exit
;
207 ret
= ldap_rename( ld
, dn
? dnU
: "", newdnU
, NULL
, delete, NULL
, NULL
, &msg
);
209 if (ret
== LDAP_SUCCESS
)
222 /***********************************************************************
223 * ldap_modrdn2_sA (WLDAP32.@)
225 * See ldap_modrdn2_sW.
227 ULONG CDECL
ldap_modrdn2_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
, INT
delete )
229 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
231 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
233 ret
= WLDAP32_LDAP_NO_MEMORY
;
235 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
237 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
244 newdnW
= strAtoW( newdn
);
245 if (!newdnW
) goto exit
;
247 ret
= ldap_modrdn2_sW( ld
, dnW
, newdnW
, delete );
257 /***********************************************************************
258 * ldap_modrdn2_sW (WLDAP32.@)
260 * Change the RDN of a directory entry (synchronous operation).
263 * ld [I] Pointer to an LDAP context.
264 * dn [I] DN of the entry to change.
265 * newdn [I] New DN for the entry.
266 * delete [I] Delete old DN?
269 * Success: LDAP_SUCCESS
270 * Failure: An LDAP error code.
272 ULONG CDECL
ldap_modrdn2_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
, INT
delete )
274 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
276 char *dnU
= NULL
, *newdnU
= NULL
;
278 ret
= WLDAP32_LDAP_NO_MEMORY
;
280 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
282 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
289 newdnU
= strWtoU( newdn
);
290 if (!newdnU
) goto exit
;
292 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newdnU
, NULL
, delete, NULL
, NULL
);
302 /***********************************************************************
303 * ldap_modrdn_sA (WLDAP32.@)
305 * See ldap_modrdn_sW.
307 ULONG CDECL
ldap_modrdn_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
)
309 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
311 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
313 ret
= WLDAP32_LDAP_NO_MEMORY
;
315 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), newdn
);
317 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
324 newdnW
= strAtoW( newdn
);
325 if (!newdnW
) goto exit
;
327 ret
= ldap_modrdn_sW( ld
, dnW
, newdnW
);
337 /***********************************************************************
338 * ldap_modrdn_sW (WLDAP32.@)
340 * Change the RDN of a directory entry (synchronous operation).
343 * ld [I] Pointer to an LDAP context.
344 * dn [I] DN of the entry to change.
345 * newdn [I] New DN for the entry.
348 * Success: LDAP_SUCCESS
349 * Failure: An LDAP error code.
351 ULONG CDECL
ldap_modrdn_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
)
353 ULONG ret
= WLDAP32_LDAP_NOT_SUPPORTED
;
355 char *dnU
= NULL
, *newdnU
= NULL
;
357 ret
= WLDAP32_LDAP_NO_MEMORY
;
359 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), newdn
);
361 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
368 newdnU
= strWtoU( newdn
);
369 if (!newdnU
) goto exit
;
371 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newdnU
, NULL
, 1, NULL
, NULL
);