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_modrdnA (WLDAP32.@)
37 ULONG CDECL
ldap_modrdnA( LDAP
*ld
, char *dn
, char *newdn
)
39 ULONG ret
= LDAP_NO_MEMORY
;
40 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
42 TRACE( "(%p, %s, %s)\n", ld
, debugstr_a(dn
), debugstr_a(newdn
) );
44 if (!ld
|| !newdn
) return ~0u;
46 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
47 if (!(newdnW
= strAtoW( newdn
))) goto exit
;
49 ret
= ldap_modrdnW( ld
, dnW
, newdnW
);
57 /***********************************************************************
58 * ldap_modrdnW (WLDAP32.@)
60 * Change the RDN of a directory entry (asynchronous operation).
63 * ld [I] Pointer to an LDAP context.
64 * dn [I] DN of the entry to change.
65 * newdn [I] New DN for the entry.
68 * Success: Message ID of the modrdn operation.
69 * Failure: An LDAP error code.
72 * Call ldap_result with the message ID to get the result of
73 * the operation. Cancel the operation by calling ldap_abandon
74 * with the message ID.
76 ULONG CDECL
ldap_modrdnW( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newdn
)
78 TRACE( "(%p, %s, %s)\n", ld
, debugstr_w(dn
), debugstr_w(newdn
) );
79 return ldap_modrdn2W( ld
, dn
, newdn
, 1 );
82 /***********************************************************************
83 * ldap_modrdn2A (WLDAP32.@)
87 ULONG CDECL
ldap_modrdn2A( LDAP
*ld
, char *dn
, char *newdn
, int delete )
89 ULONG ret
= LDAP_NO_MEMORY
;
90 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
92 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
94 if (!ld
|| !newdn
) return ~0u;
96 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
97 if (!(newdnW
= strAtoW( newdn
))) goto exit
;
99 ret
= ldap_modrdn2W( ld
, dnW
, newdnW
, delete );
107 /***********************************************************************
108 * ldap_modrdn2W (WLDAP32.@)
110 * Change the RDN of a directory entry (asynchronous operation).
113 * ld [I] Pointer to an LDAP context.
114 * dn [I] DN of the entry to change.
115 * newdn [I] New DN for the entry.
116 * delete [I] Delete old DN?
119 * Success: Message ID of the modrdn operation.
120 * Failure: An LDAP error code.
123 * Call ldap_result with the message ID to get the result of
124 * the operation. Cancel the operation by calling ldap_abandon
125 * with the message ID.
127 ULONG CDECL
ldap_modrdn2W( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newdn
, int delete )
129 ULONG ret
= LDAP_NO_MEMORY
;
130 char *dnU
= NULL
, *newdnU
= NULL
;
133 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
135 if (!ld
|| !newdn
) return ~0u;
137 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
138 if (!(newdnU
= strWtoU( newdn
))) goto exit
;
140 ret
= ldap_funcs
->fn_ldap_rename( CTX(ld
), dnU
, newdnU
, NULL
, delete, NULL
, NULL
, &msg
);
141 if (ret
== LDAP_SUCCESS
)
152 /***********************************************************************
153 * ldap_modrdn2_sA (WLDAP32.@)
155 * See ldap_modrdn2_sW.
157 ULONG CDECL
ldap_modrdn2_sA( LDAP
*ld
, char *dn
, char *newdn
, int delete )
159 ULONG ret
= LDAP_NO_MEMORY
;
160 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
162 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_a(dn
), newdn
, delete );
164 if (!ld
|| !newdn
) return LDAP_PARAM_ERROR
;
166 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
167 if (!(newdnW
= strAtoW( newdn
))) goto exit
;
169 ret
= ldap_modrdn2_sW( ld
, dnW
, newdnW
, delete );
177 /***********************************************************************
178 * ldap_modrdn2_sW (WLDAP32.@)
180 * Change the RDN of a directory entry (synchronous operation).
183 * ld [I] Pointer to an LDAP context.
184 * dn [I] DN of the entry to change.
185 * newdn [I] New DN for the entry.
186 * delete [I] Delete old DN?
189 * Success: LDAP_SUCCESS
190 * Failure: An LDAP error code.
192 ULONG CDECL
ldap_modrdn2_sW( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newdn
, int delete )
194 ULONG ret
= LDAP_NO_MEMORY
;
195 char *dnU
= NULL
, *newdnU
= NULL
;
197 TRACE( "(%p, %s, %p, 0x%02x)\n", ld
, debugstr_w(dn
), newdn
, delete );
199 if (!ld
|| !newdn
) return LDAP_PARAM_ERROR
;
201 if (dn
&& !(dnU
= strWtoU( dn
))) goto exit
;
202 if (!(newdnU
= strWtoU( newdn
))) goto exit
;
204 ret
= map_error( ldap_funcs
->fn_ldap_rename_s( CTX(ld
), dnU
, newdnU
, NULL
, delete, NULL
, NULL
));
212 /***********************************************************************
213 * ldap_modrdn_sA (WLDAP32.@)
215 * See ldap_modrdn_sW.
217 ULONG CDECL
ldap_modrdn_sA( LDAP
*ld
, char *dn
, char *newdn
)
219 ULONG ret
= LDAP_NO_MEMORY
;
220 WCHAR
*dnW
= NULL
, *newdnW
= NULL
;
222 TRACE( "(%p, %s, %p)\n", ld
, debugstr_a(dn
), newdn
);
224 if (!ld
|| !newdn
) return LDAP_PARAM_ERROR
;
226 if (dn
&& !(dnW
= strAtoW( dn
))) goto exit
;
227 if (!(newdnW
= strAtoW( newdn
))) goto exit
;
229 ret
= ldap_modrdn_sW( ld
, dnW
, newdnW
);
237 /***********************************************************************
238 * ldap_modrdn_sW (WLDAP32.@)
240 * Change the RDN of a directory entry (synchronous operation).
243 * ld [I] Pointer to an LDAP context.
244 * dn [I] DN of the entry to change.
245 * newdn [I] New DN for the entry.
248 * Success: LDAP_SUCCESS
249 * Failure: An LDAP error code.
251 ULONG CDECL
ldap_modrdn_sW( LDAP
*ld
, WCHAR
*dn
, WCHAR
*newdn
)
253 TRACE( "(%p, %s, %p)\n", ld
, debugstr_w(dn
), newdn
);
254 return ldap_modrdn2_sW( ld
, dn
, newdn
, 1 );