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

dn.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_dn2ufnA     (WLDAP32.@)
00043  *
00044  * See ldap_dn2ufnW.
00045  */
00046 PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
00047 {
00048     PCHAR ret = NULL;
00049 #ifdef HAVE_LDAP
00050     WCHAR *dnW, *retW;
00051 
00052     TRACE( "(%s)\n", debugstr_a(dn) );
00053 
00054     dnW = strAtoW( dn );
00055     if (!dnW) return NULL;
00056 
00057     retW = ldap_dn2ufnW( dnW );
00058     ret = strWtoA( retW );
00059 
00060     strfreeW( dnW );
00061     ldap_memfreeW( retW );
00062 
00063 #endif
00064     return ret;
00065 }
00066 
00067 /***********************************************************************
00068  *      ldap_dn2ufnW     (WLDAP32.@)
00069  *
00070  * Convert a DN to a user-friendly name.
00071  *
00072  * PARAMS
00073  *  dn  [I] DN to convert.
00074  *
00075  * RETURNS
00076  *  Success: Pointer to a string containing the user-friendly name. 
00077  *  Failure: NULL
00078  *
00079  * NOTES
00080  *  Free the string with ldap_memfree.
00081  */
00082 PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
00083 {
00084     PWCHAR ret = NULL;
00085 #ifdef HAVE_LDAP
00086     char *dnU, *retU;
00087 
00088     TRACE( "(%s)\n", debugstr_w(dn) );
00089 
00090     dnU = strWtoU( dn );
00091     if (!dnU) return NULL;
00092 
00093     retU = ldap_dn2ufn( dnU );
00094     ret = strUtoW( retU );
00095 
00096     strfreeU( dnU );
00097     ldap_memfree( retU );
00098 
00099 #endif
00100     return ret;
00101 }
00102 
00103 /***********************************************************************
00104  *      ldap_explode_dnA     (WLDAP32.@)
00105  *
00106  * See ldap_explode_dnW.
00107  */
00108 PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
00109 {
00110     PCHAR *ret = NULL;
00111 #ifdef HAVE_LDAP
00112     WCHAR *dnW, **retW;
00113 
00114     TRACE( "(%s, 0x%08x)\n", debugstr_a(dn), notypes );
00115 
00116     dnW = strAtoW( dn );
00117     if (!dnW) return NULL;
00118 
00119     retW = ldap_explode_dnW( dnW, notypes );
00120     ret = strarrayWtoA( retW );
00121 
00122     strfreeW( dnW );
00123     ldap_value_freeW( retW );
00124 
00125 #endif
00126     return ret;
00127 }
00128 
00129 /***********************************************************************
00130  *      ldap_explode_dnW     (WLDAP32.@)
00131  *
00132  * Break up a DN into its components.
00133  *
00134  * PARAMS
00135  *  dn       [I] DN to break up.
00136  *  notypes  [I] Remove attribute type information from the components.
00137  *
00138  * RETURNS
00139  *  Success: Pointer to a NULL-terminated array that contains the DN
00140  *           components. 
00141  *  Failure: NULL
00142  *
00143  * NOTES
00144  *  Free the string array with ldap_value_free.
00145  */
00146 PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
00147 {
00148     PWCHAR *ret = NULL;
00149 #ifdef HAVE_LDAP
00150     char *dnU, **retU;
00151 
00152     TRACE( "(%s, 0x%08x)\n", debugstr_w(dn), notypes );
00153 
00154     dnU = strWtoU( dn );
00155     if (!dnU) return NULL;
00156 
00157     retU = ldap_explode_dn( dnU, notypes );
00158     ret = strarrayUtoW( retU );
00159 
00160     strfreeU( dnU );
00161     ldap_memvfree( (void **)retU );
00162 
00163 #endif
00164     return ret;
00165 }
00166 
00167 /***********************************************************************
00168  *      ldap_get_dnA     (WLDAP32.@)
00169  *
00170  * See ldap_get_dnW.
00171  */
00172 PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
00173 {
00174     PCHAR ret = NULL;
00175 #ifdef HAVE_LDAP
00176     PWCHAR retW;
00177 
00178     TRACE( "(%p, %p)\n", ld, entry );
00179 
00180     if (!ld || !entry) return NULL;
00181 
00182     retW = ldap_get_dnW( ld, entry );
00183 
00184     ret = strWtoA( retW );
00185     ldap_memfreeW( retW );
00186 
00187 #endif
00188     return ret;
00189 }
00190 
00191 /***********************************************************************
00192  *      ldap_get_dnW     (WLDAP32.@)
00193  *
00194  * Retrieve the DN from a given LDAP message.
00195  *
00196  * PARAMS
00197  *  ld     [I] Pointer to an LDAP context.
00198  *  entry  [I] LDAPMessage structure to retrieve the DN from.
00199  *
00200  * RETURNS
00201  *  Success: Pointer to a string that contains the DN.
00202  *  Failure: NULL
00203  *
00204  * NOTES
00205  *  Free the string with ldap_memfree.
00206  */
00207 PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
00208 {
00209     PWCHAR ret = NULL;
00210 #ifdef HAVE_LDAP
00211     char *retU;
00212 
00213     TRACE( "(%p, %p)\n", ld, entry );
00214 
00215     if (!ld || !entry) return NULL;
00216 
00217     retU = ldap_get_dn( ld, entry );
00218 
00219     ret = strUtoW( retU );
00220     ldap_memfree( retU );
00221 
00222 #endif
00223     return ret;
00224 }
00225 
00226 /***********************************************************************
00227  *      ldap_ufn2dnA     (WLDAP32.@)
00228  *
00229  * See ldap_ufn2dnW.
00230  */
00231 ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
00232 {
00233     ULONG ret = WLDAP32_LDAP_SUCCESS;
00234 #ifdef HAVE_LDAP
00235     PWCHAR ufnW = NULL, dnW = NULL;
00236 
00237     TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
00238 
00239     if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
00240 
00241     *dn = NULL;
00242 
00243     if (ufn) {
00244         ufnW = strAtoW( ufn );
00245         if (!ufnW) return WLDAP32_LDAP_NO_MEMORY;
00246     }
00247 
00248     ret = ldap_ufn2dnW( ufnW, &dnW );
00249 
00250     if (dnW) {
00251         *dn = strWtoA( dnW );
00252         if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
00253     }
00254 
00255     strfreeW( ufnW );
00256     ldap_memfreeW( dnW );
00257 
00258 #endif
00259     return ret;
00260 }
00261 
00262 /***********************************************************************
00263  *      ldap_ufn2dnW     (WLDAP32.@)
00264  *
00265  * Convert a user-friendly name to a DN.
00266  *
00267  * PARAMS
00268  *  ufn  [I] User-friendly name to convert.
00269  *  dn   [O] Receives a pointer to a string containing the DN. 
00270  *
00271  * RETURNS
00272  *  Success: LDAP_SUCCESS
00273  *  Failure: An LDAP error code.
00274  *
00275  * NOTES
00276  *  Free the string with ldap_memfree.
00277  */
00278 ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
00279 {
00280     ULONG ret = WLDAP32_LDAP_SUCCESS;
00281 #ifdef HAVE_LDAP
00282     char *ufnU = NULL;
00283 
00284     TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
00285 
00286     if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
00287 
00288     *dn = NULL;
00289 
00290     if (ufn) {
00291         ufnU = strWtoU( ufn );
00292         if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
00293 
00294         /* FIXME: do more than just a copy */
00295         *dn = strUtoW( ufnU );
00296         if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
00297     }
00298 
00299     strfreeU( ufnU );
00300 
00301 #endif
00302     return ret;
00303 }

Generated on Sun May 27 2012 04:27:04 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.