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 ULONG
ldap_rename_extA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
44 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
45 PLDAPControlA
*clientctrls
, ULONG
*message
)
47 ULONG ret
= LDAP_NOT_SUPPORTED
;
49 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
50 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
52 ret
= WLDAP32_LDAP_NO_MEMORY
;
54 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_a(dn
),
55 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
56 serverctrls
, clientctrls
, message
);
58 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
65 newrdnW
= strAtoW( newrdn
);
66 if (!newrdnW
) goto exit
;
69 newparentW
= strAtoW( newparent
);
70 if (!newparentW
) goto exit
;
73 serverctrlsW
= controlarrayAtoW( serverctrls
);
74 if (!serverctrlsW
) goto exit
;
77 clientctrlsW
= controlarrayAtoW( clientctrls
);
78 if (!clientctrlsW
) goto exit
;
81 ret
= ldap_rename_extW( ld
, dnW
, newrdnW
, newparentW
, delete,
82 serverctrlsW
, clientctrlsW
, message
);
87 strfreeW( newparentW
);
88 controlarrayfreeW( serverctrlsW
);
89 controlarrayfreeW( clientctrlsW
);
95 ULONG
ldap_rename_extW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
96 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
97 PLDAPControlW
*clientctrls
, ULONG
*message
)
99 ULONG ret
= LDAP_NOT_SUPPORTED
;
101 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
102 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
104 ret
= WLDAP32_LDAP_NO_MEMORY
;
106 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld
, debugstr_w(dn
),
107 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
108 serverctrls
, clientctrls
, message
);
110 if (!ld
|| !message
) return WLDAP32_LDAP_PARAM_ERROR
;
117 newrdnU
= strWtoU( newrdn
);
118 if (!newrdnU
) goto exit
;
121 newparentU
= strWtoU( newparent
);
122 if (!newparentU
) goto exit
;
125 serverctrlsU
= controlarrayWtoU( serverctrls
);
126 if (!serverctrlsU
) goto exit
;
129 clientctrlsU
= controlarrayWtoU( clientctrls
);
130 if (!clientctrlsU
) goto exit
;
133 ret
= ldap_rename( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
134 delete, serverctrlsU
, clientctrlsU
, (int *)message
);
139 strfreeU( newparentU
);
140 controlarrayfreeU( serverctrlsU
);
141 controlarrayfreeU( clientctrlsU
);
147 ULONG
ldap_rename_ext_sA( WLDAP32_LDAP
*ld
, PCHAR dn
, PCHAR newrdn
,
148 PCHAR newparent
, INT
delete, PLDAPControlA
*serverctrls
,
149 PLDAPControlA
*clientctrls
)
151 ULONG ret
= LDAP_NOT_SUPPORTED
;
153 WCHAR
*dnW
= NULL
, *newrdnW
= NULL
, *newparentW
= NULL
;
154 LDAPControlW
**serverctrlsW
= NULL
, **clientctrlsW
= NULL
;
156 ret
= WLDAP32_LDAP_NO_MEMORY
;
158 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_a(dn
),
159 debugstr_a(newrdn
), debugstr_a(newparent
), delete,
160 serverctrls
, clientctrls
);
162 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
169 newrdnW
= strAtoW( newrdn
);
170 if (!newrdnW
) goto exit
;
173 newparentW
= strAtoW( newparent
);
174 if (!newparentW
) goto exit
;
177 serverctrlsW
= controlarrayAtoW( serverctrls
);
178 if (!serverctrlsW
) goto exit
;
181 clientctrlsW
= controlarrayAtoW( clientctrls
);
182 if (!clientctrlsW
) goto exit
;
185 ret
= ldap_rename_ext_sW( ld
, dnW
, newrdnW
, newparentW
, delete,
186 serverctrlsW
, clientctrlsW
);
191 strfreeW( newparentW
);
192 controlarrayfreeW( serverctrlsW
);
193 controlarrayfreeW( clientctrlsW
);
199 ULONG
ldap_rename_ext_sW( WLDAP32_LDAP
*ld
, PWCHAR dn
, PWCHAR newrdn
,
200 PWCHAR newparent
, INT
delete, PLDAPControlW
*serverctrls
,
201 PLDAPControlW
*clientctrls
)
203 ULONG ret
= LDAP_NOT_SUPPORTED
;
205 char *dnU
= NULL
, *newrdnU
= NULL
, *newparentU
= NULL
;
206 LDAPControl
**serverctrlsU
= NULL
, **clientctrlsU
= NULL
;
208 ret
= WLDAP32_LDAP_NO_MEMORY
;
210 TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld
, debugstr_w(dn
),
211 debugstr_w(newrdn
), debugstr_w(newparent
), delete,
212 serverctrls
, clientctrls
);
214 if (!ld
) return WLDAP32_LDAP_PARAM_ERROR
;
221 newrdnU
= strWtoU( newrdn
);
222 if (!newrdnU
) goto exit
;
225 newparentU
= strWtoU( newparent
);
226 if (!newparentU
) goto exit
;
229 serverctrlsU
= controlarrayWtoU( serverctrls
);
230 if (!serverctrlsU
) goto exit
;
233 clientctrlsU
= controlarrayWtoU( clientctrls
);
234 if (!clientctrlsU
) goto exit
;
237 ret
= ldap_rename_s( ld
, dn
? dnU
: "", newrdn
? newrdnU
: "", newparentU
,
238 delete, serverctrlsU
, clientctrlsU
);
243 strfreeU( newparentU
);
244 controlarrayfreeU( serverctrlsU
);
245 controlarrayfreeU( clientctrlsU
);