Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpage.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 #ifndef LDAP_MAXINT 00040 #define LDAP_MAXINT 2147483647 00041 #endif 00042 00043 WINE_DEFAULT_DEBUG_CHANNEL(wldap32); 00044 00045 /*********************************************************************** 00046 * ldap_create_page_controlA (WLDAP32.@) 00047 * 00048 * See ldap_create_page_controlW. 00049 */ 00050 ULONG CDECL ldap_create_page_controlA( WLDAP32_LDAP *ld, ULONG pagesize, 00051 struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlA *control ) 00052 { 00053 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00054 #ifdef HAVE_LDAP 00055 LDAPControlW *controlW = NULL; 00056 00057 TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, 00058 critical, control ); 00059 00060 if (!ld || !control || pagesize > LDAP_MAXINT) 00061 return WLDAP32_LDAP_PARAM_ERROR; 00062 00063 ret = ldap_create_page_controlW( ld, pagesize, cookie, critical, &controlW ); 00064 if (ret == LDAP_SUCCESS) 00065 { 00066 *control = controlWtoA( controlW ); 00067 ldap_control_freeW( controlW ); 00068 } 00069 00070 #endif 00071 return ret; 00072 } 00073 00074 #ifdef HAVE_LDAP 00075 00076 /* create a page control by hand */ 00077 static ULONG create_page_control( ULONG pagesize, struct WLDAP32_berval *cookie, 00078 UCHAR critical, PLDAPControlW *control ) 00079 { 00080 LDAPControlW *ctrl; 00081 BerElement *ber; 00082 ber_tag_t tag; 00083 struct berval *berval, null_cookie = { 0, NULL }; 00084 INT ret, len; 00085 char *val; 00086 00087 ber = ber_alloc_t( LBER_USE_DER ); 00088 if (!ber) return WLDAP32_LDAP_NO_MEMORY; 00089 00090 if (cookie) 00091 tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, cookie ); 00092 else 00093 tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, &null_cookie ); 00094 00095 ret = ber_flatten( ber, &berval ); 00096 ber_free( ber, 1 ); 00097 00098 if (tag == LBER_ERROR) 00099 return WLDAP32_LDAP_ENCODING_ERROR; 00100 00101 if (ret == -1) 00102 return WLDAP32_LDAP_NO_MEMORY; 00103 00104 /* copy the berval so it can be properly freed by the caller */ 00105 val = HeapAlloc( GetProcessHeap(), 0, berval->bv_len ); 00106 if (!val) return WLDAP32_LDAP_NO_MEMORY; 00107 00108 len = berval->bv_len; 00109 memcpy( val, berval->bv_val, len ); 00110 ber_bvfree( berval ); 00111 00112 ctrl = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) ); 00113 if (!ctrl) 00114 { 00115 HeapFree( GetProcessHeap(), 0, val ); 00116 return WLDAP32_LDAP_NO_MEMORY; 00117 } 00118 00119 ctrl->ldctl_oid = strAtoW( LDAP_PAGED_RESULT_OID_STRING ); 00120 ctrl->ldctl_value.bv_len = len; 00121 ctrl->ldctl_value.bv_val = val; 00122 ctrl->ldctl_iscritical = critical; 00123 00124 *control = ctrl; 00125 00126 return WLDAP32_LDAP_SUCCESS; 00127 } 00128 00129 #endif /* HAVE_LDAP */ 00130 00131 /*********************************************************************** 00132 * ldap_create_page_controlW (WLDAP32.@) 00133 * 00134 * Create a control for paged search results. 00135 * 00136 * PARAMS 00137 * ld [I] Pointer to an LDAP context. 00138 * pagesize [I] Number of entries to return per page. 00139 * cookie [I] Used by the server to track its location in the 00140 * search results. 00141 * critical [I] Tells the server this control is critical to the 00142 * search operation. 00143 * control [O] LDAPControl created. 00144 * 00145 * RETURNS 00146 * Success: LDAP_SUCCESS 00147 * Failure: An LDAP error code. 00148 */ 00149 ULONG CDECL ldap_create_page_controlW( WLDAP32_LDAP *ld, ULONG pagesize, 00150 struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlW *control ) 00151 { 00152 #ifdef HAVE_LDAP 00153 TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, 00154 critical, control ); 00155 00156 if (!ld || !control || pagesize > LDAP_MAXINT) 00157 return WLDAP32_LDAP_PARAM_ERROR; 00158 00159 return create_page_control( pagesize, cookie, critical, control ); 00160 00161 #else 00162 return WLDAP32_LDAP_NOT_SUPPORTED; 00163 #endif 00164 } 00165 00166 ULONG CDECL ldap_get_next_page( WLDAP32_LDAP *ld, PLDAPSearch search, ULONG pagesize, 00167 ULONG *message ) 00168 { 00169 FIXME( "(%p, %p, 0x%08x, %p)\n", ld, search, pagesize, message ); 00170 00171 if (!ld) return ~0u; 00172 return WLDAP32_LDAP_NOT_SUPPORTED; 00173 } 00174 00175 ULONG CDECL ldap_get_next_page_s( WLDAP32_LDAP *ld, PLDAPSearch search, 00176 struct l_timeval *timeout, ULONG pagesize, ULONG *count, 00177 WLDAP32_LDAPMessage **results ) 00178 { 00179 FIXME( "(%p, %p, %p, 0x%08x, %p, %p)\n", ld, search, timeout, 00180 pagesize, count, results ); 00181 00182 if (!ld) return ~0u; 00183 return WLDAP32_LDAP_NOT_SUPPORTED; 00184 } 00185 00186 ULONG CDECL ldap_get_paged_count( WLDAP32_LDAP *ld, PLDAPSearch search, 00187 ULONG *count, WLDAP32_LDAPMessage *results ) 00188 { 00189 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00190 #ifdef HAVE_LDAP 00191 FIXME( "(%p, %p, %p, %p)\n", ld, search, count, results ); 00192 00193 if (!ld) return WLDAP32_LDAP_PARAM_ERROR; 00194 /* FIXME: save the cookie from the server here */ 00195 00196 #endif 00197 return ret; 00198 } 00199 00200 /*********************************************************************** 00201 * ldap_parse_page_controlA (WLDAP32.@) 00202 */ 00203 ULONG CDECL ldap_parse_page_controlA( WLDAP32_LDAP *ld, PLDAPControlA *ctrls, 00204 ULONG *count, struct WLDAP32_berval **cookie ) 00205 { 00206 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00207 #ifdef HAVE_LDAP 00208 LDAPControlW **ctrlsW = NULL; 00209 00210 TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie ); 00211 00212 if (!ld || !ctrls || !count || !cookie) 00213 return WLDAP32_LDAP_PARAM_ERROR; 00214 00215 ctrlsW = controlarrayAtoW( ctrls ); 00216 if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY; 00217 00218 ret = ldap_parse_page_controlW( ld, ctrlsW, count, cookie ); 00219 controlarrayfreeW( ctrlsW ); 00220 00221 #endif 00222 return ret; 00223 } 00224 00225 /*********************************************************************** 00226 * ldap_parse_page_controlW (WLDAP32.@) 00227 */ 00228 ULONG CDECL ldap_parse_page_controlW( WLDAP32_LDAP *ld, PLDAPControlW *ctrls, 00229 ULONG *count, struct WLDAP32_berval **cookie ) 00230 { 00231 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00232 #ifdef HAVE_LDAP 00233 LDAPControlW *control = NULL; 00234 BerElement *ber; 00235 ber_tag_t tag; 00236 ULONG i; 00237 00238 TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie ); 00239 00240 if (!ld || !ctrls || !count || !cookie) 00241 return WLDAP32_LDAP_PARAM_ERROR; 00242 00243 for (i = 0; ctrls[i]; i++) 00244 { 00245 if (!lstrcmpW( LDAP_PAGED_RESULT_OID_STRING_W, ctrls[i]->ldctl_oid )) 00246 control = ctrls[i]; 00247 } 00248 00249 if (!control) 00250 return WLDAP32_LDAP_CONTROL_NOT_FOUND; 00251 00252 ber = ber_init( &((LDAPControl *)control)->ldctl_value ); 00253 if (!ber) 00254 return WLDAP32_LDAP_NO_MEMORY; 00255 00256 tag = ber_scanf( ber, "{iO}", count, cookie ); 00257 if ( tag == LBER_ERROR ) 00258 ret = WLDAP32_LDAP_DECODING_ERROR; 00259 else 00260 ret = WLDAP32_LDAP_SUCCESS; 00261 00262 ber_free( ber, 1 ); 00263 00264 #endif 00265 return ret; 00266 } 00267 00268 ULONG CDECL ldap_search_abandon_page( WLDAP32_LDAP *ld, PLDAPSearch search ) 00269 { 00270 FIXME( "(%p, %p)\n", ld, search ); 00271 00272 if (!ld) return ~0u; 00273 return WLDAP32_LDAP_SUCCESS; 00274 } 00275 00276 PLDAPSearch CDECL ldap_search_init_pageA( WLDAP32_LDAP *ld, PCHAR dn, ULONG scope, 00277 PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls, 00278 PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyA *sortkeys ) 00279 { 00280 FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(dn), 00281 scope, debugstr_a(filter), attrs, attrsonly ); 00282 return NULL; 00283 } 00284 00285 PLDAPSearch CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR dn, ULONG scope, 00286 PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls, 00287 PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyW *sortkeys ) 00288 { 00289 FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), 00290 scope, debugstr_w(filter), attrs, attrsonly ); 00291 return NULL; 00292 } Generated on Thu May 24 2012 04:27:34 for ReactOS by
1.7.6.1
|