ReactOS Fundraising Campaign 2012
 
€ 4,060 / € 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

modrdn.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 /***********************************************************************
00042  *      ldap_modrdnA     (WLDAP32.@)
00043  *
00044  * See ldap_modrdnW.
00045  */
00046 ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
00047 {
00048     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00049 #ifdef HAVE_LDAP
00050     WCHAR *dnW = NULL, *newdnW = NULL;
00051 
00052     ret = WLDAP32_LDAP_NO_MEMORY;
00053 
00054     TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
00055 
00056     if (!ld || !newdn) return ~0u;
00057 
00058     if (dn) {
00059         dnW = strAtoW( dn );
00060         if (!dnW) goto exit;
00061     }
00062 
00063     newdnW = strAtoW( newdn );
00064     if (!newdnW) goto exit;
00065 
00066     ret = ldap_modrdnW( ld, dnW, newdnW );
00067 
00068 exit:
00069     strfreeW( dnW );
00070     strfreeW( newdnW );
00071 
00072 #endif
00073     return ret;
00074 }
00075 
00076 /***********************************************************************
00077  *      ldap_modrdnW     (WLDAP32.@)
00078  *
00079  * Change the RDN of a directory entry (asynchronous operation).
00080  *
00081  * PARAMS
00082  *  ld      [I] Pointer to an LDAP context.
00083  *  dn      [I] DN of the entry to change.
00084  *  newdn   [I] New DN for the entry. 
00085  *
00086  * RETURNS
00087  *  Success: Message ID of the modrdn operation.
00088  *  Failure: An LDAP error code.
00089  *
00090  * NOTES
00091  *  Call ldap_result with the message ID to get the result of
00092  *  the operation. Cancel the operation by calling ldap_abandon
00093  *  with the message ID.
00094  */
00095 ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
00096 {
00097     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00098 #ifdef HAVE_LDAP
00099     char *dnU = NULL, *newdnU = NULL;
00100     int msg;
00101 
00102     ret = WLDAP32_LDAP_NO_MEMORY;
00103 
00104     TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
00105 
00106     if (!ld || !newdn) return ~0u;
00107 
00108     if (dn) {
00109         dnU = strWtoU( dn );
00110         if (!dnU) goto exit;
00111     }
00112 
00113     newdnU = strWtoU( newdn );
00114     if (!newdnU) goto exit;
00115 
00116     ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
00117 
00118     if (ret == LDAP_SUCCESS)
00119         ret = msg;
00120     else
00121         ret = ~0u;
00122 
00123 exit:
00124     strfreeU( dnU );
00125     strfreeU( newdnU );
00126 
00127 #endif
00128     return ret;
00129 }
00130 
00131 /***********************************************************************
00132  *      ldap_modrdn2A     (WLDAP32.@)
00133  *
00134  * See ldap_modrdn2W.
00135  */
00136 ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
00137 {
00138     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00139 #ifdef HAVE_LDAP
00140     WCHAR *dnW = NULL, *newdnW = NULL;
00141 
00142     ret = WLDAP32_LDAP_NO_MEMORY;
00143 
00144     TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
00145 
00146     if (!ld || !newdn) return ~0u;
00147 
00148     if (dn) {
00149         dnW = strAtoW( dn );
00150         if (!dnW) goto exit;
00151     }
00152 
00153     newdnW = strAtoW( newdn );
00154     if (!newdnW) goto exit;
00155 
00156     ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
00157 
00158 exit:
00159     strfreeW( dnW );
00160     strfreeW( newdnW );
00161 
00162 #endif
00163     return ret;
00164 }
00165 
00166 /***********************************************************************
00167  *      ldap_modrdn2W     (WLDAP32.@)
00168  *
00169  * Change the RDN of a directory entry (asynchronous operation).
00170  *
00171  * PARAMS
00172  *  ld      [I] Pointer to an LDAP context.
00173  *  dn      [I] DN of the entry to change.
00174  *  newdn   [I] New DN for the entry. 
00175  *  delete  [I] Delete old DN?
00176  *
00177  * RETURNS
00178  *  Success: Message ID of the modrdn operation.
00179  *  Failure: An LDAP error code.
00180  *
00181  * NOTES
00182  *  Call ldap_result with the message ID to get the result of
00183  *  the operation. Cancel the operation by calling ldap_abandon
00184  *  with the message ID.
00185  */
00186 ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
00187 {
00188     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00189 #ifdef HAVE_LDAP
00190     char *dnU = NULL, *newdnU = NULL;
00191     int msg;
00192 
00193     ret = WLDAP32_LDAP_NO_MEMORY;
00194 
00195     TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
00196 
00197     if (!ld || !newdn) return ~0u;
00198 
00199     if (dn) {
00200         dnU = strWtoU( dn );
00201         if (!dnU) goto exit;
00202     }
00203 
00204     newdnU = strWtoU( newdn );
00205     if (!newdnU) goto exit;
00206 
00207     ret = ldap_rename( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
00208 
00209     if (ret == LDAP_SUCCESS)
00210         ret = msg;
00211     else
00212         ret = ~0u;
00213 
00214 exit:
00215     strfreeU( dnU );
00216     strfreeU( newdnU );
00217 
00218 #endif
00219     return ret;
00220 }
00221 
00222 /***********************************************************************
00223  *      ldap_modrdn2_sA     (WLDAP32.@)
00224  *
00225  * See ldap_modrdn2_sW.
00226  */
00227 ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
00228 {
00229     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00230 #ifdef HAVE_LDAP
00231     WCHAR *dnW = NULL, *newdnW = NULL;
00232 
00233     ret = WLDAP32_LDAP_NO_MEMORY;
00234 
00235     TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
00236 
00237     if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
00238 
00239     if (dn) {
00240         dnW = strAtoW( dn );
00241         if (!dnW) goto exit;
00242     }
00243 
00244     newdnW = strAtoW( newdn );
00245     if (!newdnW) goto exit;
00246 
00247     ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
00248 
00249 exit:
00250     strfreeW( dnW );
00251     strfreeW( newdnW );
00252 
00253 #endif
00254     return ret;
00255 }
00256 
00257 /***********************************************************************
00258  *      ldap_modrdn2_sW     (WLDAP32.@)
00259  *
00260  * Change the RDN of a directory entry (synchronous operation).
00261  *
00262  * PARAMS
00263  *  ld      [I] Pointer to an LDAP context.
00264  *  dn      [I] DN of the entry to change.
00265  *  newdn   [I] New DN for the entry. 
00266  *  delete  [I] Delete old DN?
00267  *
00268  * RETURNS
00269  *  Success: LDAP_SUCCESS
00270  *  Failure: An LDAP error code.
00271  */
00272 ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
00273 {
00274     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00275 #ifdef HAVE_LDAP
00276     char *dnU = NULL, *newdnU = NULL;
00277 
00278     ret = WLDAP32_LDAP_NO_MEMORY;
00279 
00280     TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
00281 
00282     if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
00283 
00284     if (dn) {
00285         dnU = strWtoU( dn );
00286         if (!dnU) goto exit;
00287     }
00288 
00289     newdnU = strWtoU( newdn );
00290     if (!newdnU) goto exit;
00291 
00292     ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL ));
00293 
00294 exit:
00295     strfreeU( dnU );
00296     strfreeU( newdnU );
00297 
00298 #endif
00299     return ret;
00300 }
00301 
00302 /***********************************************************************
00303  *      ldap_modrdn_sA     (WLDAP32.@)
00304  *
00305  * See ldap_modrdn_sW.
00306  */
00307 ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
00308 {
00309     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00310 #ifdef HAVE_LDAP
00311     WCHAR *dnW = NULL, *newdnW = NULL;
00312 
00313     ret = WLDAP32_LDAP_NO_MEMORY;
00314 
00315     TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
00316 
00317     if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
00318 
00319     if (dn) {
00320         dnW = strAtoW( dn );
00321         if (!dnW) goto exit;
00322     }
00323 
00324     newdnW = strAtoW( newdn );
00325     if (!newdnW) goto exit;
00326 
00327     ret = ldap_modrdn_sW( ld, dnW, newdnW );
00328 
00329 exit:
00330     strfreeW( dnW );
00331     strfreeW( newdnW );
00332 
00333 #endif
00334     return ret;
00335 }
00336 
00337 /***********************************************************************
00338  *      ldap_modrdn_sW     (WLDAP32.@)
00339  *
00340  * Change the RDN of a directory entry (synchronous operation).
00341  *
00342  * PARAMS
00343  *  ld      [I] Pointer to an LDAP context.
00344  *  dn      [I] DN of the entry to change.
00345  *  newdn   [I] New DN for the entry. 
00346  *
00347  * RETURNS
00348  *  Success: LDAP_SUCCESS
00349  *  Failure: An LDAP error code.
00350  */
00351 ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
00352 {
00353     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
00354 #ifdef HAVE_LDAP
00355     char *dnU = NULL, *newdnU = NULL;
00356 
00357     ret = WLDAP32_LDAP_NO_MEMORY;
00358 
00359     TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
00360 
00361     if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
00362 
00363     if (dn) {
00364         dnU = strWtoU( dn );
00365         if (!dnU) goto exit;
00366     }
00367 
00368     newdnU = strWtoU( newdn );
00369     if (!newdnU) goto exit;
00370 
00371     ret = map_error( ldap_rename_s( ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL ));
00372 
00373 exit:
00374     strfreeU( dnU );
00375     strfreeU( newdnU );
00376 
00377 #endif
00378     return ret;
00379 }

Generated on Tue May 22 2012 04:30:55 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.