Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmodify.c
Go to the documentation of this file.
00001 /* 00002 * WLDAP32 - LDAP support for Wine 00003 * 00004 * Copyright 2005 Hans Leidekker 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include "config.h" 00022 00023 #include "wine/port.h" 00024 #include "wine/debug.h" 00025 00026 #include <stdarg.h> 00027 00028 #include "windef.h" 00029 #include "winbase.h" 00030 #include "winnls.h" 00031 00032 #ifdef HAVE_LDAP_H 00033 #include <ldap.h> 00034 #endif 00035 00036 #include "winldap_private.h" 00037 #include "wldap32.h" 00038 00039 WINE_DEFAULT_DEBUG_CHANNEL(wldap32); 00040 00041 #ifdef HAVE_LDAP 00042 static LDAPMod *nullmods[] = { NULL }; 00043 #endif 00044 00045 /*********************************************************************** 00046 * ldap_modifyA (WLDAP32.@) 00047 * 00048 * See ldap_modifyW. 00049 */ 00050 ULONG CDECL ldap_modifyA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] ) 00051 { 00052 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00053 #ifdef HAVE_LDAP 00054 WCHAR *dnW = NULL; 00055 LDAPModW **modsW = NULL; 00056 00057 ret = WLDAP32_LDAP_NO_MEMORY; 00058 00059 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods ); 00060 00061 if (!ld) return ~0u; 00062 00063 if (dn) { 00064 dnW = strAtoW( dn ); 00065 if (!dnW) goto exit; 00066 } 00067 if (mods) { 00068 modsW = modarrayAtoW( mods ); 00069 if (!modsW) goto exit; 00070 } 00071 00072 ret = ldap_modifyW( ld, dnW, modsW ); 00073 00074 exit: 00075 strfreeW( dnW ); 00076 modarrayfreeW( modsW ); 00077 00078 #endif 00079 return ret; 00080 } 00081 00082 /*********************************************************************** 00083 * ldap_modifyW (WLDAP32.@) 00084 * 00085 * Change an entry in a directory tree (asynchronous operation). 00086 * 00087 * PARAMS 00088 * ld [I] Pointer to an LDAP context. 00089 * dn [I] DN of the entry to change. 00090 * mods [I] Pointer to an array of LDAPModW structures, each 00091 * specifying an attribute and its values to change. 00092 * 00093 * RETURNS 00094 * Success: Message ID of the modify operation. 00095 * Failure: An LDAP error code. 00096 * 00097 * NOTES 00098 * Call ldap_result with the message ID to get the result of 00099 * the operation. Cancel the operation by calling ldap_abandon 00100 * with the message ID. 00101 */ 00102 ULONG CDECL ldap_modifyW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] ) 00103 { 00104 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00105 #ifdef HAVE_LDAP 00106 char *dnU = NULL; 00107 LDAPMod **modsU = NULL; 00108 int msg; 00109 00110 ret = WLDAP32_LDAP_NO_MEMORY; 00111 00112 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods ); 00113 00114 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00115 00116 if (dn) { 00117 dnU = strWtoU( dn ); 00118 if (!dnU) goto exit; 00119 } 00120 if (mods) { 00121 modsU = modarrayWtoU( mods ); 00122 if (!modsU) goto exit; 00123 } 00124 00125 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods, 00126 NULL, NULL, &msg ); 00127 00128 if (ret == LDAP_SUCCESS) 00129 ret = msg; 00130 else 00131 ret = ~0u; 00132 00133 exit: 00134 strfreeU( dnU ); 00135 modarrayfreeU( modsU ); 00136 00137 #endif 00138 return ret; 00139 } 00140 00141 /*********************************************************************** 00142 * ldap_modify_extA (WLDAP32.@) 00143 * 00144 * See ldap_modify_extW. 00145 */ 00146 ULONG CDECL ldap_modify_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[], 00147 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message ) 00148 { 00149 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00150 #ifdef HAVE_LDAP 00151 WCHAR *dnW = NULL; 00152 LDAPModW **modsW = NULL; 00153 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL; 00154 00155 ret = WLDAP32_LDAP_NO_MEMORY; 00156 00157 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods, 00158 serverctrls, clientctrls, message ); 00159 00160 if (!ld) return ~0u; 00161 00162 if (dn) { 00163 dnW = strAtoW( dn ); 00164 if (!dnW) goto exit; 00165 } 00166 if (mods) { 00167 modsW = modarrayAtoW( mods ); 00168 if (!modsW) goto exit; 00169 } 00170 if (serverctrls) { 00171 serverctrlsW = controlarrayAtoW( serverctrls ); 00172 if (!serverctrlsW) goto exit; 00173 } 00174 if (clientctrls) { 00175 clientctrlsW = controlarrayAtoW( clientctrls ); 00176 if (!clientctrlsW) goto exit; 00177 } 00178 00179 ret = ldap_modify_extW( ld, dnW, modsW, serverctrlsW, clientctrlsW, message ); 00180 00181 exit: 00182 strfreeW( dnW ); 00183 modarrayfreeW( modsW ); 00184 controlarrayfreeW( serverctrlsW ); 00185 controlarrayfreeW( clientctrlsW ); 00186 00187 #endif 00188 return ret; 00189 } 00190 00191 /*********************************************************************** 00192 * ldap_modify_extW (WLDAP32.@) 00193 * 00194 * Change an entry in a directory tree (asynchronous operation). 00195 * 00196 * PARAMS 00197 * ld [I] Pointer to an LDAP context. 00198 * dn [I] DN of the entry to change. 00199 * mods [I] Pointer to an array of LDAPModW structures, each 00200 * specifying an attribute and its values to change. 00201 * serverctrls [I] Array of LDAP server controls. 00202 * clientctrls [I] Array of LDAP client controls. 00203 * message [O] Message ID of the modify operation. 00204 * 00205 * RETURNS 00206 * Success: LDAP_SUCCESS 00207 * Failure: An LDAP error code. 00208 * 00209 * NOTES 00210 * Call ldap_result with the message ID to get the result of 00211 * the operation. The serverctrls and clientctrls parameters are 00212 * optional and should be set to NULL if not used. 00213 */ 00214 ULONG CDECL ldap_modify_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[], 00215 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message ) 00216 { 00217 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00218 #ifdef HAVE_LDAP 00219 char *dnU = NULL; 00220 LDAPMod **modsU = NULL; 00221 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; 00222 int dummy; 00223 00224 ret = WLDAP32_LDAP_NO_MEMORY; 00225 00226 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods, 00227 serverctrls, clientctrls, message ); 00228 00229 if (!ld) return ~0u; 00230 00231 if (dn) { 00232 dnU = strWtoU( dn ); 00233 if (!dnU) goto exit; 00234 } 00235 if (mods) { 00236 modsU = modarrayWtoU( mods ); 00237 if (!modsU) goto exit; 00238 } 00239 if (serverctrls) { 00240 serverctrlsU = controlarrayWtoU( serverctrls ); 00241 if (!serverctrlsU) goto exit; 00242 } 00243 if (clientctrls) { 00244 clientctrlsU = controlarrayWtoU( clientctrls ); 00245 if (!clientctrlsU) goto exit; 00246 } 00247 00248 ret = map_error( ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods, serverctrlsU, 00249 clientctrlsU, message ? (int *)message : &dummy )); 00250 00251 exit: 00252 strfreeU( dnU ); 00253 modarrayfreeU( modsU ); 00254 controlarrayfreeU( serverctrlsU ); 00255 controlarrayfreeU( clientctrlsU ); 00256 00257 #endif 00258 return ret; 00259 } 00260 00261 /*********************************************************************** 00262 * ldap_modify_ext_sA (WLDAP32.@) 00263 * 00264 * See ldap_modify_ext_sW. 00265 */ 00266 ULONG CDECL ldap_modify_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[], 00267 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls ) 00268 { 00269 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00270 #ifdef HAVE_LDAP 00271 WCHAR *dnW = NULL; 00272 LDAPModW **modsW = NULL; 00273 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL; 00274 00275 ret = WLDAP32_LDAP_NO_MEMORY; 00276 00277 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods, 00278 serverctrls, clientctrls ); 00279 00280 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00281 00282 if (dn) { 00283 dnW = strAtoW( dn ); 00284 if (!dnW) goto exit; 00285 } 00286 if (mods) { 00287 modsW = modarrayAtoW( mods ); 00288 if (!modsW) goto exit; 00289 } 00290 if (serverctrls) { 00291 serverctrlsW = controlarrayAtoW( serverctrls ); 00292 if (!serverctrlsW) goto exit; 00293 } 00294 if (clientctrls) { 00295 clientctrlsW = controlarrayAtoW( clientctrls ); 00296 if (!clientctrlsW) goto exit; 00297 } 00298 00299 ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW ); 00300 00301 exit: 00302 strfreeW( dnW ); 00303 modarrayfreeW( modsW ); 00304 controlarrayfreeW( serverctrlsW ); 00305 controlarrayfreeW( clientctrlsW ); 00306 00307 #endif 00308 return ret; 00309 } 00310 00311 /*********************************************************************** 00312 * ldap_modify_ext_sW (WLDAP32.@) 00313 * 00314 * Change an entry in a directory tree (synchronous operation). 00315 * 00316 * PARAMS 00317 * ld [I] Pointer to an LDAP context. 00318 * dn [I] DN of the entry to change. 00319 * mods [I] Pointer to an array of LDAPModW structures, each 00320 * specifying an attribute and its values to change. 00321 * serverctrls [I] Array of LDAP server controls. 00322 * clientctrls [I] Array of LDAP client controls. 00323 * 00324 * RETURNS 00325 * Success: LDAP_SUCCESS 00326 * Failure: An LDAP error code. 00327 * 00328 * NOTES 00329 * The serverctrls and clientctrls parameters are optional and 00330 * should be set to NULL if not used. 00331 */ 00332 ULONG CDECL ldap_modify_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[], 00333 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls ) 00334 { 00335 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00336 #ifdef HAVE_LDAP 00337 char *dnU = NULL; 00338 LDAPMod **modsU = NULL; 00339 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; 00340 00341 ret = WLDAP32_LDAP_NO_MEMORY; 00342 00343 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods, 00344 serverctrls, clientctrls ); 00345 00346 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00347 00348 if (dn) { 00349 dnU = strWtoU( dn ); 00350 if (!dnU) goto exit; 00351 } 00352 if (mods) { 00353 modsU = modarrayWtoU( mods ); 00354 if (!modsU) goto exit; 00355 } 00356 if (serverctrls) { 00357 serverctrlsU = controlarrayWtoU( serverctrls ); 00358 if (!serverctrlsU) goto exit; 00359 } 00360 if (clientctrls) { 00361 clientctrlsU = controlarrayWtoU( clientctrls ); 00362 if (!clientctrlsU) goto exit; 00363 } 00364 00365 ret = map_error( ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods, 00366 serverctrlsU, clientctrlsU )); 00367 00368 exit: 00369 strfreeU( dnU ); 00370 modarrayfreeU( modsU ); 00371 controlarrayfreeU( serverctrlsU ); 00372 controlarrayfreeU( clientctrlsU ); 00373 00374 #endif 00375 return ret; 00376 } 00377 00378 /*********************************************************************** 00379 * ldap_modify_sA (WLDAP32.@) 00380 * 00381 * See ldap_modify_sW. 00382 */ 00383 ULONG CDECL ldap_modify_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] ) 00384 { 00385 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00386 #ifdef HAVE_LDAP 00387 WCHAR *dnW = NULL; 00388 LDAPModW **modsW = NULL; 00389 00390 ret = WLDAP32_LDAP_NO_MEMORY; 00391 00392 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods ); 00393 00394 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00395 00396 if (dn) { 00397 dnW = strAtoW( dn ); 00398 if (!dnW) goto exit; 00399 } 00400 if (mods) { 00401 modsW = modarrayAtoW( mods ); 00402 if (!modsW) goto exit; 00403 } 00404 00405 ret = ldap_modify_sW( ld, dnW, modsW ); 00406 00407 exit: 00408 strfreeW( dnW ); 00409 modarrayfreeW( modsW ); 00410 00411 #endif 00412 return ret; 00413 } 00414 00415 /*********************************************************************** 00416 * ldap_modify_sW (WLDAP32.@) 00417 * 00418 * Change an entry in a directory tree (synchronous operation). 00419 * 00420 * PARAMS 00421 * ld [I] Pointer to an LDAP context. 00422 * dn [I] DN of the entry to change. 00423 * attrs [I] Pointer to an array of LDAPModW structures, each 00424 * specifying an attribute and its values to change. 00425 * 00426 * RETURNS 00427 * Success: LDAP_SUCCESS 00428 * Failure: An LDAP error code. 00429 */ 00430 ULONG CDECL ldap_modify_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] ) 00431 { 00432 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00433 #ifdef HAVE_LDAP 00434 char *dnU = NULL; 00435 LDAPMod **modsU = NULL; 00436 00437 ret = WLDAP32_LDAP_NO_MEMORY; 00438 00439 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods ); 00440 00441 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00442 00443 if (dn) { 00444 dnU = strWtoU( dn ); 00445 if (!dnU) goto exit; 00446 } 00447 if (mods) { 00448 modsU = modarrayWtoU( mods ); 00449 if (!modsU) goto exit; 00450 } 00451 00452 ret = map_error( ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods, NULL, NULL )); 00453 00454 exit: 00455 strfreeU( dnU ); 00456 modarrayfreeU( modsU ); 00457 00458 #endif 00459 return ret; 00460 } Generated on Fri May 25 2012 04:22:06 for ReactOS by
1.7.6.1
|