Avoid using deprecated openldap functions.
[wine/wine64.git] / dlls / wldap32 / modrdn.c
bloba572fe75046603a94b152798197a6f8f7bdd812a
1 /*
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_NOT_SUPPORTED 0x5c
36 #endif
38 #include "winldap_private.h"
39 #include "wldap32.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 ULONG ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
45 ULONG ret = LDAP_NOT_SUPPORTED;
46 #ifdef HAVE_LDAP
47 WCHAR *dnW = NULL, *newdnW = NULL;
49 ret = WLDAP32_LDAP_NO_MEMORY;
51 TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
53 if (!ld || !newdn) return ~0UL;
55 if (dn) {
56 dnW = strAtoW( dn );
57 if (!dnW) goto exit;
60 newdnW = strAtoW( newdn );
61 if (!newdnW) goto exit;
63 ret = ldap_modrdnW( ld, dnW, newdnW );
65 exit:
66 strfreeW( dnW );
67 strfreeW( newdnW );
69 #endif
70 return ret;
73 ULONG ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
75 ULONG ret = LDAP_NOT_SUPPORTED;
76 #ifdef HAVE_LDAP
77 char *dnU = NULL, *newdnU = NULL;
78 int msg;
80 ret = WLDAP32_LDAP_NO_MEMORY;
82 TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
84 if (!ld || !newdn) return ~0UL;
86 if (dn) {
87 dnU = strWtoU( dn );
88 if (!dnU) goto exit;
91 newdnU = strWtoU( newdn );
92 if (!newdnU) goto exit;
94 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
96 if (ret == LDAP_SUCCESS)
97 ret = msg;
98 else
99 ret = ~0UL;
101 exit:
102 strfreeU( dnU );
103 strfreeU( newdnU );
105 #endif
106 return ret;
109 ULONG ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
111 ULONG ret = LDAP_NOT_SUPPORTED;
112 #ifdef HAVE_LDAP
113 WCHAR *dnW = NULL, *newdnW = NULL;
115 ret = WLDAP32_LDAP_NO_MEMORY;
117 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
119 if (!ld || !newdn) return ~0UL;
121 if (dn) {
122 dnW = strAtoW( dn );
123 if (!dnW) goto exit;
126 newdnW = strAtoW( newdn );
127 if (!newdnW) goto exit;
129 ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
131 exit:
132 strfreeW( dnW );
133 strfreeW( newdnW );
135 #endif
136 return ret;
139 ULONG ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
141 ULONG ret = LDAP_NOT_SUPPORTED;
142 #ifdef HAVE_LDAP
143 char *dnU = NULL, *newdnU = NULL;
144 int msg;
146 ret = WLDAP32_LDAP_NO_MEMORY;
148 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
150 if (!ld || !newdn) return ~0UL;
152 if (dn) {
153 dnU = strWtoU( dn );
154 if (!dnU) goto exit;
157 newdnU = strWtoU( newdn );
158 if (!newdnU) goto exit;
160 ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
162 if (ret == LDAP_SUCCESS)
163 ret = msg;
164 else
165 ret = ~0UL;
167 exit:
168 strfreeU( dnU );
169 strfreeU( newdnU );
171 #endif
172 return ret;
175 ULONG ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
177 ULONG ret = LDAP_NOT_SUPPORTED;
178 #ifdef HAVE_LDAP
179 WCHAR *dnW = NULL, *newdnW = NULL;
181 ret = WLDAP32_LDAP_NO_MEMORY;
183 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
185 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
187 if (dn) {
188 dnW = strAtoW( dn );
189 if (!dnW) goto exit;
192 newdnW = strAtoW( newdn );
193 if (!newdnW) goto exit;
195 ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
197 exit:
198 strfreeW( dnW );
199 strfreeW( newdnW );
201 #endif
202 return ret;
205 ULONG ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
207 ULONG ret = LDAP_NOT_SUPPORTED;
208 #ifdef HAVE_LDAP
209 char *dnU = NULL, *newdnU = NULL;
211 ret = WLDAP32_LDAP_NO_MEMORY;
213 TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
215 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
217 if (dn) {
218 dnU = strWtoU( dn );
219 if (!dnU) goto exit;
222 newdnU = strWtoU( newdn );
223 if (!newdnU) goto exit;
225 ret = ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL );
227 exit:
228 strfreeU( dnU );
229 strfreeU( newdnU );
231 #endif
232 return ret;
235 ULONG ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
237 ULONG ret = LDAP_NOT_SUPPORTED;
238 #ifdef HAVE_LDAP
239 WCHAR *dnW = NULL, *newdnW = NULL;
241 ret = WLDAP32_LDAP_NO_MEMORY;
243 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
245 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
247 if (dn) {
248 dnW = strAtoW( dn );
249 if (!dnW) goto exit;
252 newdnW = strAtoW( newdn );
253 if (!newdnW) goto exit;
255 ret = ldap_modrdn_sW( ld, dnW, newdnW );
257 exit:
258 strfreeW( dnW );
259 strfreeW( newdnW );
261 #endif
262 return ret;
265 ULONG ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
267 ULONG ret = LDAP_NOT_SUPPORTED;
268 #ifdef HAVE_LDAP
269 char *dnU = NULL, *newdnU = NULL;
271 ret = WLDAP32_LDAP_NO_MEMORY;
273 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
275 if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
277 if (dn) {
278 dnU = strWtoU( dn );
279 if (!dnU) goto exit;
282 newdnU = strWtoU( newdn );
283 if (!newdnU) goto exit;
285 ret = ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL );
287 exit:
288 strfreeU( dnU );
289 strfreeU( newdnU );
291 #endif
292 return ret;