Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenextended.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_close_extended_op (WLDAP32.@) 00043 * 00044 * Close an extended operation. 00045 * 00046 * PARAMS 00047 * ld [I] Pointer to an LDAP context. 00048 * msgid [I] Message ID of the operation to be closed. 00049 * 00050 * RETURNS 00051 * Success: LDAP_SUCCESS 00052 * Failure: An LDAP error code. 00053 * 00054 * NOTES 00055 * Contrary to native, OpenLDAP does not require us to close 00056 * extended operations, so this is a no-op. 00057 */ 00058 ULONG CDECL ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid ) 00059 { 00060 TRACE( "(%p, 0x%08x)\n", ld, msgid ); 00061 00062 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00063 return WLDAP32_LDAP_SUCCESS; 00064 } 00065 00066 /*********************************************************************** 00067 * ldap_extended_operationA (WLDAP32.@) 00068 * 00069 * See ldap_extended_operationW. 00070 */ 00071 ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data, 00072 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message ) 00073 { 00074 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00075 #ifdef HAVE_LDAP 00076 WCHAR *oidW = NULL; 00077 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL; 00078 00079 ret = WLDAP32_LDAP_NO_MEMORY; 00080 00081 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, 00082 clientctrls, message ); 00083 00084 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR; 00085 00086 if (oid) { 00087 oidW = strAtoW( oid ); 00088 if (!oidW) goto exit; 00089 } 00090 if (serverctrls) { 00091 serverctrlsW = controlarrayAtoW( serverctrls ); 00092 if (!serverctrlsW) goto exit; 00093 } 00094 if (clientctrls) { 00095 clientctrlsW = controlarrayAtoW( clientctrls ); 00096 if (!clientctrlsW) goto exit; 00097 } 00098 00099 ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message ); 00100 00101 exit: 00102 strfreeW( oidW ); 00103 controlarrayfreeW( serverctrlsW ); 00104 controlarrayfreeW( clientctrlsW ); 00105 00106 #endif 00107 return ret; 00108 } 00109 00110 /*********************************************************************** 00111 * ldap_extended_operationW (WLDAP32.@) 00112 * 00113 * Perform an extended operation (asynchronous mode). 00114 * 00115 * PARAMS 00116 * ld [I] Pointer to an LDAP context. 00117 * oid [I] OID of the extended operation. 00118 * data [I] Data needed by the operation. 00119 * serverctrls [I] Array of LDAP server controls. 00120 * clientctrls [I] Array of LDAP client controls. 00121 * message [O] Message ID of the extended operation. 00122 * 00123 * RETURNS 00124 * Success: LDAP_SUCCESS 00125 * Failure: An LDAP error code. 00126 * 00127 * NOTES 00128 * The data parameter should be set to NULL if the operation 00129 * requires no data. Call ldap_result with the message ID to 00130 * get the result of the operation or ldap_abandon to cancel 00131 * the operation. The serverctrls and clientctrls parameters 00132 * are optional and should be set to NULL if not used. Call 00133 * ldap_close_extended_op to close the operation. 00134 */ 00135 ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data, 00136 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message ) 00137 { 00138 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00139 #ifdef HAVE_LDAP 00140 char *oidU = NULL; 00141 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; 00142 00143 ret = WLDAP32_LDAP_NO_MEMORY; 00144 00145 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, 00146 clientctrls, message ); 00147 00148 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR; 00149 00150 if (oid) { 00151 oidU = strWtoU( oid ); 00152 if (!oidU) goto exit; 00153 } 00154 if (serverctrls) { 00155 serverctrlsU = controlarrayWtoU( serverctrls ); 00156 if (!serverctrlsU) goto exit; 00157 } 00158 if (clientctrls) { 00159 clientctrlsU = controlarrayWtoU( clientctrls ); 00160 if (!clientctrlsU) goto exit; 00161 } 00162 00163 ret = map_error( ldap_extended_operation( ld, oid ? oidU : "", (struct berval *)data, 00164 serverctrlsU, clientctrlsU, (int *)message )); 00165 00166 exit: 00167 strfreeU( oidU ); 00168 controlarrayfreeU( serverctrlsU ); 00169 controlarrayfreeU( clientctrlsU ); 00170 00171 #endif 00172 return ret; 00173 } 00174 00175 /*********************************************************************** 00176 * ldap_extended_operation_sA (WLDAP32.@) 00177 * 00178 * See ldap_extended_operation_sW. 00179 */ 00180 ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data, 00181 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid, 00182 struct WLDAP32_berval **retdata ) 00183 { 00184 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00185 #ifdef HAVE_LDAP 00186 WCHAR *oidW = NULL, *retoidW = NULL; 00187 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL; 00188 00189 ret = WLDAP32_LDAP_NO_MEMORY; 00190 00191 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, 00192 clientctrls, retoid, retdata ); 00193 00194 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00195 00196 if (oid) { 00197 oidW = strAtoW( oid ); 00198 if (!oidW) goto exit; 00199 } 00200 if (serverctrls) { 00201 serverctrlsW = controlarrayAtoW( serverctrls ); 00202 if (!serverctrlsW) goto exit; 00203 } 00204 if (clientctrls) { 00205 clientctrlsW = controlarrayAtoW( clientctrls ); 00206 if (!clientctrlsW) goto exit; 00207 } 00208 00209 ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW, 00210 &retoidW, retdata ); 00211 00212 if (retoid && retoidW) { 00213 *retoid = strWtoA( retoidW ); 00214 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY; 00215 ldap_memfreeW( retoidW ); 00216 } 00217 00218 exit: 00219 strfreeW( oidW ); 00220 controlarrayfreeW( serverctrlsW ); 00221 controlarrayfreeW( clientctrlsW ); 00222 00223 #endif 00224 return ret; 00225 } 00226 00227 /*********************************************************************** 00228 * ldap_extended_operation_sW (WLDAP32.@) 00229 * 00230 * Perform an extended operation (synchronous mode). 00231 * 00232 * PARAMS 00233 * ld [I] Pointer to an LDAP context. 00234 * oid [I] OID of the extended operation. 00235 * data [I] Data needed by the operation. 00236 * serverctrls [I] Array of LDAP server controls. 00237 * clientctrls [I] Array of LDAP client controls. 00238 * retoid [O] OID of the server response message. 00239 * retdata [O] Data returned by the server. 00240 * 00241 * RETURNS 00242 * Success: LDAP_SUCCESS 00243 * Failure: An LDAP error code. 00244 * 00245 * NOTES 00246 * The data parameter should be set to NULL if the operation 00247 * requires no data. The serverctrls, clientctrls, retoid and 00248 * and retdata parameters are also optional. Set to NULL if not 00249 * used. Free retoid and retdata after use with ldap_memfree. 00250 */ 00251 ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data, 00252 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid, 00253 struct WLDAP32_berval **retdata ) 00254 { 00255 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00256 #ifdef HAVE_LDAP 00257 char *oidU = NULL, *retoidU = NULL; 00258 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL; 00259 00260 ret = WLDAP32_LDAP_NO_MEMORY; 00261 00262 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, 00263 clientctrls, retoid, retdata ); 00264 00265 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00266 00267 if (oid) { 00268 oidU = strWtoU( oid ); 00269 if (!oidU) goto exit; 00270 } 00271 if (serverctrls) { 00272 serverctrlsU = controlarrayWtoU( serverctrls ); 00273 if (!serverctrlsU) goto exit; 00274 } 00275 if (clientctrls) { 00276 clientctrlsU = controlarrayWtoU( clientctrls ); 00277 if (!clientctrlsU) goto exit; 00278 } 00279 00280 ret = map_error( ldap_extended_operation_s( ld, oid ? oidU : "", (struct berval *)data, serverctrlsU, 00281 clientctrlsU, &retoidU, (struct berval **)retdata )); 00282 00283 if (retoid && retoidU) { 00284 *retoid = strUtoW( retoidU ); 00285 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY; 00286 ldap_memfree( retoidU ); 00287 } 00288 00289 exit: 00290 strfreeU( oidU ); 00291 controlarrayfreeU( serverctrlsU ); 00292 controlarrayfreeU( clientctrlsU ); 00293 00294 #endif 00295 return ret; 00296 } Generated on Sun May 27 2012 04:27:04 for ReactOS by
1.7.6.1
|