ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

add.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 *nullattrs[] = { NULL };
00043 #endif
00044 
00045 /***********************************************************************
00046  *      ldap_addA     (WLDAP32.@)
00047  *
00048  * See ldap_addW.
00049  */
00050 ULONG CDECL ldap_addA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[] )
00051 {
00052     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00053 #ifdef HAVE_LDAP
00054     WCHAR *dnW = NULL;
00055     LDAPModW **attrsW = NULL;
00056 
00057     ret = WLDAP32_LDAP_NO_MEMORY;
00058 
00059     TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
00060 
00061     if (!ld) return ~0u;
00062 
00063     if (dn) {
00064         dnW = strAtoW( dn );
00065         if (!dnW) goto exit;
00066     }
00067     if (attrs) {
00068         attrsW = modarrayAtoW( attrs );
00069         if (!attrsW) goto exit;
00070     }
00071 
00072     ret = ldap_addW( ld, dnW, attrsW );
00073 
00074 exit:
00075     strfreeW( dnW );
00076     modarrayfreeW( attrsW );
00077 
00078 #endif
00079     return ret;
00080 }
00081 
00082 /***********************************************************************
00083  *      ldap_addW     (WLDAP32.@)
00084  *
00085  * Add an entry to a directory tree (asynchronous operation).
00086  *
00087  * PARAMS
00088  *  ld      [I] Pointer to an LDAP context.
00089  *  dn      [I] DN of the entry to add.
00090  *  attrs   [I] Pointer to an array of LDAPModW structures, each
00091  *              specifying an attribute and its values to add.
00092  *
00093  * RETURNS
00094  *  Success: Message ID of the add 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_addW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
00103 {
00104     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00105 #ifdef HAVE_LDAP
00106     char *dnU = NULL;
00107     LDAPMod **attrsU = NULL;
00108     int msg;
00109  
00110     ret = WLDAP32_LDAP_NO_MEMORY;
00111 
00112     TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
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 (attrs) {
00121         attrsU = modarrayWtoU( attrs );
00122         if (!attrsU) goto exit;
00123     }
00124 
00125     ret = ldap_add_ext( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, NULL, NULL, &msg );
00126 
00127     if (ret == LDAP_SUCCESS)
00128         ret = msg;
00129     else
00130         ret = ~0u;
00131 
00132 exit:
00133     strfreeU( dnU );
00134     modarrayfreeU( attrsU );
00135 
00136 #endif
00137     return ret;
00138 }
00139 
00140 /***********************************************************************
00141  *      ldap_add_extA     (WLDAP32.@)
00142  *
00143  * See ldap_add_extW.
00144  */
00145 ULONG CDECL ldap_add_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[],
00146     PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
00147 {
00148     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00149 #ifdef HAVE_LDAP
00150     WCHAR *dnW = NULL;
00151     LDAPModW **attrsW = NULL;
00152     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
00153 
00154     ret = WLDAP32_LDAP_NO_MEMORY;
00155 
00156     TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), attrs,
00157            serverctrls, clientctrls, message );
00158 
00159     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00160 
00161     if (dn) {
00162         dnW = strAtoW( dn );
00163         if (!dnW) goto exit;
00164     }
00165     if (attrs) {
00166         attrsW = modarrayAtoW( attrs );
00167         if (!attrsW) goto exit;
00168     }
00169     if (serverctrls) {
00170         serverctrlsW = controlarrayAtoW( serverctrls );
00171         if (!serverctrlsW) goto exit;
00172     }
00173     if (clientctrls) {
00174         clientctrlsW = controlarrayAtoW( clientctrls );
00175         if (!clientctrlsW) goto exit;
00176     }
00177 
00178     ret = ldap_add_extW( ld, dnW, attrsW, serverctrlsW, clientctrlsW, message );
00179 
00180 exit:
00181     strfreeW( dnW );
00182     modarrayfreeW( attrsW );
00183     controlarrayfreeW( serverctrlsW );
00184     controlarrayfreeW( clientctrlsW );
00185 
00186 #endif
00187     return ret;
00188 }
00189 
00190 /***********************************************************************
00191  *      ldap_add_extW     (WLDAP32.@)
00192  *
00193  * Add an entry to a directory tree (asynchronous operation).
00194  *
00195  * PARAMS
00196  *  ld          [I] Pointer to an LDAP context.
00197  *  dn          [I] DN of the entry to add.
00198  *  attrs       [I] Pointer to an array of LDAPModW structures, each
00199  *                  specifying an attribute and its values to add.
00200  *  serverctrls [I] Array of LDAP server controls.
00201  *  clientctrls [I] Array of LDAP client controls.
00202  *  message     [O] Message ID of the add operation.
00203  *
00204  * RETURNS
00205  *  Success: LDAP_SUCCESS
00206  *  Failure: An LDAP error code.
00207  *
00208  * NOTES
00209  *  Call ldap_result with the message ID to get the result of
00210  *  the operation. The serverctrls and clientctrls parameters are
00211  *  optional and should be set to NULL if not used.
00212  */
00213 ULONG CDECL ldap_add_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
00214     PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
00215 {
00216     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00217 #ifdef HAVE_LDAP
00218     char *dnU = NULL;
00219     LDAPMod **attrsU = NULL;
00220     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
00221     int dummy;
00222 
00223     ret = WLDAP32_LDAP_NO_MEMORY;
00224 
00225     TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), attrs,
00226            serverctrls, clientctrls, message );
00227 
00228     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00229 
00230     if (dn) {
00231         dnU = strWtoU( dn );
00232         if (!dnU) goto exit;
00233     }
00234     if (attrs) {
00235         attrsU = modarrayWtoU( attrs );
00236         if (!attrsU) goto exit;
00237     }
00238     if (serverctrls) {
00239         serverctrlsU = controlarrayWtoU( serverctrls );
00240         if (!serverctrlsU) goto exit;
00241     }
00242     if (clientctrls) {
00243         clientctrlsU = controlarrayWtoU( clientctrls );
00244         if (!clientctrlsU) goto exit;
00245     }
00246 
00247     ret = map_error( ldap_add_ext( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, serverctrlsU,
00248                                    clientctrlsU, message ? (int *)message : &dummy ));
00249 
00250 exit:
00251     strfreeU( dnU );
00252     modarrayfreeU( attrsU );
00253     controlarrayfreeU( serverctrlsU );
00254     controlarrayfreeU( clientctrlsU );
00255 
00256 #endif
00257     return ret;
00258 }
00259 
00260 /***********************************************************************
00261  *      ldap_add_ext_sA     (WLDAP32.@)
00262  *
00263  * See ldap_add_ext_sW.
00264  */
00265 ULONG CDECL ldap_add_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[],
00266     PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
00267 {
00268     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00269 #ifdef HAVE_LDAP
00270     WCHAR *dnW = NULL;
00271     LDAPModW **attrsW = NULL;
00272     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
00273 
00274     ret = WLDAP32_LDAP_NO_MEMORY;
00275 
00276     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), attrs,
00277            serverctrls, clientctrls );
00278 
00279     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00280 
00281     if (dn) {
00282         dnW = strAtoW( dn );
00283         if (!dnW) goto exit;
00284     }
00285     if (attrs) {
00286         attrsW = modarrayAtoW( attrs );
00287         if (!attrsW) goto exit;
00288     }
00289     if (serverctrls) {
00290         serverctrlsW = controlarrayAtoW( serverctrls );
00291         if (!serverctrlsW) goto exit;
00292     }
00293     if (clientctrls) {
00294         clientctrlsW = controlarrayAtoW( clientctrls );
00295         if (!clientctrlsW) goto exit;
00296     }
00297 
00298     ret = ldap_add_ext_sW( ld, dnW, attrsW, serverctrlsW, clientctrlsW );
00299 
00300 exit:
00301     strfreeW( dnW );
00302     modarrayfreeW( attrsW );
00303     controlarrayfreeW( serverctrlsW );
00304     controlarrayfreeW( clientctrlsW );
00305 
00306 #endif
00307     return ret;
00308 }
00309 
00310 /***********************************************************************
00311  *      ldap_add_ext_sW     (WLDAP32.@)
00312  *
00313  * Add an entry to a directory tree (synchronous operation).
00314  *
00315  * PARAMS
00316  *  ld          [I] Pointer to an LDAP context.
00317  *  dn          [I] DN of the entry to add.
00318  *  attrs       [I] Pointer to an array of LDAPModW structures, each
00319  *                  specifying an attribute and its values to add.
00320  *  serverctrls [I] Array of LDAP server controls.
00321  *  clientctrls [I] Array of LDAP client controls.
00322  *
00323  * RETURNS
00324  *  Success: LDAP_SUCCESS
00325  *  Failure: An LDAP error code.
00326  *
00327  * NOTES
00328  *  The serverctrls and clientctrls parameters are optional and
00329  *  should be set to NULL if not used.
00330  */
00331 ULONG CDECL ldap_add_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[],
00332     PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
00333 {
00334     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00335 #ifdef HAVE_LDAP
00336     char *dnU = NULL;
00337     LDAPMod **attrsU = NULL;
00338     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
00339 
00340     ret = WLDAP32_LDAP_NO_MEMORY;
00341 
00342     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), attrs,
00343            serverctrls, clientctrls );
00344 
00345     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00346 
00347     if (dn) {
00348         dnU = strWtoU( dn );
00349         if (!dnU) goto exit;
00350     }
00351     if (attrs) {
00352         attrsU = modarrayWtoU( attrs );
00353         if (!attrsU) goto exit;
00354     }
00355     if (serverctrls) {
00356         serverctrlsU = controlarrayWtoU( serverctrls );
00357         if (!serverctrlsU) goto exit;
00358     }
00359     if (clientctrls) {
00360         clientctrlsU = controlarrayWtoU( clientctrls );
00361         if (!clientctrlsU) goto exit;
00362     }
00363 
00364     ret = map_error( ldap_add_ext_s( ld, dn ? dnU : "", attrs ? attrsU : nullattrs,
00365                                      serverctrlsU, clientctrlsU ));
00366 
00367 exit:
00368     strfreeU( dnU );
00369     modarrayfreeU( attrsU );
00370     controlarrayfreeU( serverctrlsU );
00371     controlarrayfreeU( clientctrlsU );
00372 
00373 #endif
00374     return ret;
00375 }
00376 
00377 /***********************************************************************
00378  *      ldap_add_sA     (WLDAP32.@)
00379  *
00380  * See ldap_add_sW.
00381  */
00382 ULONG CDECL ldap_add_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *attrs[] )
00383 {
00384     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00385 #ifdef HAVE_LDAP
00386     WCHAR *dnW = NULL;
00387     LDAPModW **attrsW = NULL;
00388 
00389     ret = WLDAP32_LDAP_NO_MEMORY;
00390 
00391     TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
00392 
00393     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00394 
00395     if (dn) {
00396         dnW = strAtoW( dn );
00397         if (!dnW) goto exit;
00398     }
00399     if (attrs) {
00400         attrsW = modarrayAtoW( attrs );
00401         if (!attrsW) goto exit;
00402     }
00403 
00404     ret = ldap_add_sW( ld, dnW, attrsW );
00405 
00406 exit:
00407     strfreeW( dnW );
00408     modarrayfreeW( attrsW );
00409 
00410 #endif
00411     return ret;
00412 }
00413 
00414 /***********************************************************************
00415  *      ldap_add_sW     (WLDAP32.@)
00416  *
00417  * Add an entry to a directory tree (synchronous operation).
00418  *
00419  * PARAMS
00420  *  ld      [I] Pointer to an LDAP context.
00421  *  dn      [I] DN of the entry to add.
00422  *  attrs   [I] Pointer to an array of LDAPModW structures, each
00423  *              specifying an attribute and its values to add.
00424  *
00425  * RETURNS
00426  *  Success: LDAP_SUCCESS
00427  *  Failure: An LDAP error code.
00428  */
00429 ULONG CDECL ldap_add_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *attrs[] )
00430 {
00431     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00432 #ifdef HAVE_LDAP
00433     char *dnU = NULL;
00434     LDAPMod **attrsU = NULL;
00435 
00436     ret = WLDAP32_LDAP_NO_MEMORY;
00437 
00438     TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
00439 
00440     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
00441 
00442     if (dn) {
00443         dnU = strWtoU( dn );
00444         if (!dnU) goto exit;
00445     }
00446     if (attrs) {
00447         attrsU = modarrayWtoU( attrs );
00448         if (!attrsU) goto exit;
00449     }
00450 
00451     ret = map_error( ldap_add_ext_s( ld, dn ? dnU : "", attrs ? attrsU : nullattrs, NULL, NULL ));
00452 
00453 exit:
00454     strfreeU( dnU );
00455     modarrayfreeU( attrsU );
00456 
00457 #endif
00458     return ret;
00459 }

Generated on Wed May 23 2012 04:16:45 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.