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"
35 #define LDAP_NOT_SUPPORTED 0x5c
38 #include "winldap_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32
);
43 /***********************************************************************
44 * ldap_modrdnA (WLDAP32.@)
48 ULONG CDECL
ldap_modrdnA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
)
50 ULONG ret
= LDAP_NOT_SUPPORTED
;
52 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
54 ret
= WLDAP32_LDAP_NO_MEMORY
;
56 TRACE( "(%p, %s, %s)\n", ld
, debugstr_a(dn
), debugstr_a(newdn
) );
58 if (!ld
|| !newdn
) return ~0UL;
65 newdnW
= strAtoW( newdn
);
66 if (!newdnW
) goto exit
;
68 ret
= ldap_modrdnW( ld
, dnW
, newdnW
);
78 /***********************************************************************
79 * ldap_modrdnW (WLDAP32.@)
81 * Change the RDN of a directory entry (asynchronous operation).
84 * ld [I] Pointer to an LDAP context.
85 * dn [I] DN of the entry to change.
86 * newdn [I] New DN for the entry.
89 * Success: Message ID of the modrdn operation.
90 * Failure: An LDAP error code.
93 * Call ldap_result with the message ID to get the result of
94 * the operation. Cancel the operation by calling ldap_abandon
95 * with the message ID.
97 ULONG CDECL
ldap_modrdnW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
)
99 ULONG ret
= LDAP_NOT_SUPPORTED
;
101 char *dnU
= NULL
, *newdnU
= NULL
;
104 ret
= WLDAP32_LDAP_NO_MEMORY
;
106 TRACE( "(%p, %s, %s)\n", ld
, debugstr_w(dn
), debugstr_w(newdn
) );
108 if (!ld
|| !newdn
) return ~0UL;
115 newdnU
= strWtoU( newdn
);
116 if (!newdnU
) goto exit
;
118 ret
= ldap_rename( ld
, dn
? dnU
: "", newdnU
, NULL
, 1, NULL
, NULL
, &msg
);
120 if (ret
== LDAP_SUCCESS
)
133 /***********************************************************************
134 * ldap_modrdn2A (WLDAP32.@)
138 ULONG CDECL
ldap_modrdn2A( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
, INT
delete )
140 ULONG ret
= LDAP_NOT_SUPPORTED
;
142 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
144 ret
= WLDAP32_LDAP_NO_MEMORY
;
146 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
148 if (!ld
|| !newdn
) return ~0UL;
155 newdnW
= strAtoW( newdn
);
156 if (!newdnW
) goto exit
;
158 ret
= ldap_modrdn2W( ld
, dnW
, newdnW
, delete );
168 /***********************************************************************
169 * ldap_modrdn2W (WLDAP32.@)
171 * Change the RDN of a directory entry (asynchronous operation).
174 * ld [I] Pointer to an LDAP context.
175 * dn [I] DN of the entry to change.
176 * newdn [I] New DN for the entry.
177 * delete [I] Delete old DN?
180 * Success: Message ID of the modrdn operation.
181 * Failure: An LDAP error code.
184 * Call ldap_result with the message ID to get the result of
185 * the operation. Cancel the operation by calling ldap_abandon
186 * with the message ID.
188 ULONG CDECL
ldap_modrdn2W( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
, INT
delete )
190 ULONG ret
= LDAP_NOT_SUPPORTED
;
192 char *dnU
= NULL
, *newdnU
= NULL
;
195 ret
= WLDAP32_LDAP_NO_MEMORY
;
197 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
199 if (!ld
|| !newdn
) return ~0UL;
206 newdnU
= strWtoU( newdn
);
207 if (!newdnU
) goto exit
;
209 ret
= ldap_rename( ld
, dn
? dnU
: "", newdnU
, NULL
, delete, NULL
, NULL
, &msg
);
211 if (ret
== LDAP_SUCCESS
)
224 /***********************************************************************
225 * ldap_modrdn2_sA (WLDAP32.@)
227 * See ldap_modrdn2_sW.
229 ULONG CDECL
ldap_modrdn2_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
, INT
delete )
231 ULONG ret
= LDAP_NOT_SUPPORTED
;
233 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
235 ret
= WLDAP32_LDAP_NO_MEMORY
;
237 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
239 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
246 newdnW
= strAtoW( newdn
);
247 if (!newdnW
) goto exit
;
249 ret
= ldap_modrdn2_sW( ld
, dnW
, newdnW
, delete );
259 /***********************************************************************
260 * ldap_modrdn2_sW (WLDAP32.@)
262 * Change the RDN of a directory entry (synchronous operation).
265 * ld [I] Pointer to an LDAP context.
266 * dn [I] DN of the entry to change.
267 * newdn [I] New DN for the entry.
268 * delete [I] Delete old DN?
271 * Success: LDAP_SUCCESS
272 * Failure: An LDAP error code.
274 ULONG CDECL
ldap_modrdn2_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
, INT
delete )
276 ULONG ret
= LDAP_NOT_SUPPORTED
;
278 char *dnU
= NULL
, *newdnU
= NULL
;
280 ret
= WLDAP32_LDAP_NO_MEMORY
;
282 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
284 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
291 newdnU
= strWtoU( newdn
);
292 if (!newdnU
) goto exit
;
294 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newdnU
, NULL
, delete, NULL
, NULL
);
304 /***********************************************************************
305 * ldap_modrdn_sA (WLDAP32.@)
307 * See ldap_modrdn_sW.
309 ULONG CDECL
ldap_modrdn_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newdn
)
311 ULONG ret
= LDAP_NOT_SUPPORTED
;
313 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
315 ret
= WLDAP32_LDAP_NO_MEMORY
;
317 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), newdn
);
319 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
326 newdnW
= strAtoW( newdn
);
327 if (!newdnW
) goto exit
;
329 ret
= ldap_modrdn_sW( ld
, dnW
, newdnW
);
339 /***********************************************************************
340 * ldap_modrdn_sW (WLDAP32.@)
342 * Change the RDN of a directory entry (synchronous operation).
345 * ld [I] Pointer to an LDAP context.
346 * dn [I] DN of the entry to change.
347 * newdn [I] New DN for the entry.
350 * Success: LDAP_SUCCESS
351 * Failure: An LDAP error code.
353 ULONG CDECL
ldap_modrdn_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newdn
)
355 ULONG ret
= LDAP_NOT_SUPPORTED
;
357 char *dnU
= NULL
, *newdnU
= NULL
;
359 ret
= WLDAP32_LDAP_NO_MEMORY
;
361 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), newdn
);
363 if (!ld
|| !newdn
) return WLDAP32_LDAP_PARAM_ERROR
;
370 newdnU
= strWtoU( newdn
);
371 if (!newdnU
) goto exit
;
373 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newdnU
, NULL
, 1, NULL
, NULL
);