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_rename_extA (WLDAP32.@)
46 * See ldap_rename_extW.
48 ULONG CDECL
ldap_rename_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
49 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
50 PLDAPControlA
*clientctrls
, ULONG
*message
)
52 ULONG ret
= LDAP_NOT_SUPPORTED
;
54 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
55 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
57 ret
= WLDAP32_LDAP_NO_MEMORY
;
59 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_a(dn
),
60 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
61 serverctrls
, clientctrls
, message
);
63 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
70 newrdnW
= strAtoW( newrdn
);
71 if (!newrdnW
) goto exit
;
74 newparentW
= strAtoW( newparent
);
75 if (!newparentW
) goto exit
;
78 serverctrlsW
= controlarrayAtoW( serverctrls
);
79 if (!serverctrlsW
) goto exit
;
82 clientctrlsW
= controlarrayAtoW( clientctrls
);
83 if (!clientctrlsW
) goto exit
;
86 ret
= ldap_rename_extW( ld
, dnW
, newrdnW
, newparentW
, delete,
87 serverctrlsW
, clientctrlsW
, message
);
92 strfreeW( newparentW
);
93 controlarrayfreeW( serverctrlsW
);
94 controlarrayfreeW( clientctrlsW
);
100 /***********************************************************************
101 * ldap_rename_extW (WLDAP32.@)
103 * Change the DN of a directory entry (asynchronous operation).
106 * ld [I] Pointer to an LDAP context.
107 * dn [I] DN of the entry to change.
108 * newrdn [I] New RDN for the entry.
109 * newparent [I] New parent for the entry.
110 * delete [I] Delete old RDN?
111 * serverctrls [I] Array of LDAP server controls.
112 * clientctrls [I] Array of LDAP client controls.
113 * message [O] Message ID of the operation.
116 * Success: LDAP_SUCCESS
117 * Failure: An LDAP error code.
120 * Call ldap_result with the message ID to get the result of
121 * the operation. Cancel the operation by calling ldap_abandon
122 * with the message ID.
124 ULONG CDECL
ldap_rename_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
125 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
126 PLDAPControlW
*clientctrls
, ULONG
*message
)
128 ULONG ret
= LDAP_NOT_SUPPORTED
;
130 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
131 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
133 ret
= WLDAP32_LDAP_NO_MEMORY
;
135 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_w(dn
),
136 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
137 serverctrls
, clientctrls
, message
);
139 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
146 newrdnU
= strWtoU( newrdn
);
147 if (!newrdnU
) goto exit
;
150 newparentU
= strWtoU( newparent
);
151 if (!newparentU
) goto exit
;
154 serverctrlsU
= controlarrayWtoU( serverctrls
);
155 if (!serverctrlsU
) goto exit
;
158 clientctrlsU
= controlarrayWtoU( clientctrls
);
159 if (!clientctrlsU
) goto exit
;
162 ret
= ldap_rename( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
163 delete, serverctrlsU
, clientctrlsU
, (int *)message
);
168 strfreeU( newparentU
);
169 controlarrayfreeU( serverctrlsU
);
170 controlarrayfreeU( clientctrlsU
);
176 /***********************************************************************
177 * ldap_rename_ext_sA (WLDAP32.@)
179 * See ldap_rename_ext_sW.
181 ULONG CDECL
ldap_rename_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
182 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
183 PLDAPControlA
*clientctrls
)
185 ULONG ret
= LDAP_NOT_SUPPORTED
;
187 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
188 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
190 ret
= WLDAP32_LDAP_NO_MEMORY
;
192 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_a(dn
),
193 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
194 serverctrls
, clientctrls
);
196 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
203 newrdnW
= strAtoW( newrdn
);
204 if (!newrdnW
) goto exit
;
207 newparentW
= strAtoW( newparent
);
208 if (!newparentW
) goto exit
;
211 serverctrlsW
= controlarrayAtoW( serverctrls
);
212 if (!serverctrlsW
) goto exit
;
215 clientctrlsW
= controlarrayAtoW( clientctrls
);
216 if (!clientctrlsW
) goto exit
;
219 ret
= ldap_rename_ext_sW( ld
, dnW
, newrdnW
, newparentW
, delete,
220 serverctrlsW
, clientctrlsW
);
225 strfreeW( newparentW
);
226 controlarrayfreeW( serverctrlsW
);
227 controlarrayfreeW( clientctrlsW
);
232 /***********************************************************************
233 * ldap_rename_ext_sW (WLDAP32.@)
235 * Change the DN of a directory entry (synchronous operation).
238 * ld [I] Pointer to an LDAP context.
239 * dn [I] DN of the entry to change.
240 * newrdn [I] New RDN for the entry.
241 * newparent [I] New parent for the entry.
242 * delete [I] Delete old RDN?
243 * serverctrls [I] Array of LDAP server controls.
244 * clientctrls [I] Array of LDAP client controls.
247 * Success: LDAP_SUCCESS
248 * Failure: An LDAP error code.
250 ULONG CDECL
ldap_rename_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
251 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
252 PLDAPControlW
*clientctrls
)
254 ULONG ret
= LDAP_NOT_SUPPORTED
;
256 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
257 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
259 ret
= WLDAP32_LDAP_NO_MEMORY
;
261 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_w(dn
),
262 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
263 serverctrls
, clientctrls
);
265 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
272 newrdnU
= strWtoU( newrdn
);
273 if (!newrdnU
) goto exit
;
276 newparentU
= strWtoU( newparent
);
277 if (!newparentU
) goto exit
;
280 serverctrlsU
= controlarrayWtoU( serverctrls
);
281 if (!serverctrlsU
) goto exit
;
284 clientctrlsU
= controlarrayWtoU( clientctrls
);
285 if (!clientctrlsU
) goto exit
;
288 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
289 delete, serverctrlsU
, clientctrlsU
);
294 strfreeU( newparentU
);
295 controlarrayfreeU( serverctrlsU
);
296 controlarrayfreeU( clientctrlsU
);