Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenerror.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 "winuser.h" 00031 #include "winnls.h" 00032 00033 #ifdef HAVE_LDAP_H 00034 #include <ldap.h> 00035 #endif 00036 00037 #include "winldap_private.h" 00038 #include "wldap32.h" 00039 00040 extern HINSTANCE hwldap32; 00041 00042 WINE_DEFAULT_DEBUG_CHANNEL(wldap32); 00043 00044 ULONG map_error( int error ) 00045 { 00046 switch (error) 00047 { 00048 #ifdef HAVE_LDAP_H 00049 case LDAP_SERVER_DOWN: return WLDAP32_LDAP_SERVER_DOWN; 00050 case LDAP_LOCAL_ERROR: return WLDAP32_LDAP_LOCAL_ERROR; 00051 case LDAP_DECODING_ERROR: return WLDAP32_LDAP_DECODING_ERROR; 00052 case LDAP_TIMEOUT: return WLDAP32_LDAP_TIMEOUT; 00053 case LDAP_AUTH_UNKNOWN: return WLDAP32_LDAP_AUTH_UNKNOWN; 00054 case LDAP_FILTER_ERROR: return WLDAP32_LDAP_FILTER_ERROR; 00055 case LDAP_USER_CANCELLED: return WLDAP32_LDAP_USER_CANCELLED; 00056 case LDAP_PARAM_ERROR: return WLDAP32_LDAP_PARAM_ERROR; 00057 case LDAP_NO_MEMORY: return WLDAP32_LDAP_NO_MEMORY; 00058 case LDAP_CONNECT_ERROR: return WLDAP32_LDAP_CONNECT_ERROR; 00059 case LDAP_NOT_SUPPORTED: return WLDAP32_LDAP_NOT_SUPPORTED; 00060 case LDAP_CONTROL_NOT_FOUND: return WLDAP32_LDAP_CONTROL_NOT_FOUND; 00061 case LDAP_NO_RESULTS_RETURNED: return WLDAP32_LDAP_NO_RESULTS_RETURNED; 00062 case LDAP_MORE_RESULTS_TO_RETURN: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN; 00063 case LDAP_CLIENT_LOOP: return WLDAP32_LDAP_CLIENT_LOOP; 00064 case LDAP_REFERRAL_LIMIT_EXCEEDED: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED; 00065 #endif 00066 default: return error; 00067 } 00068 } 00069 00070 /*********************************************************************** 00071 * ldap_err2stringA (WLDAP32.@) 00072 * 00073 * See ldap_err2stringW. 00074 */ 00075 PCHAR CDECL ldap_err2stringA( ULONG err ) 00076 { 00077 static char buf[256] = ""; 00078 00079 TRACE( "(0x%08x)\n", err ); 00080 00081 if (err <= WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED) 00082 LoadStringA( hwldap32, err, buf, 256 ); 00083 else 00084 LoadStringA( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 ); 00085 00086 return buf; 00087 } 00088 00089 /*********************************************************************** 00090 * ldap_err2stringW (WLDAP32.@) 00091 * 00092 * Convert an error code into a string describing the error. 00093 * 00094 * PARAMS 00095 * err [I] Error code to convert. 00096 * 00097 * RETURNS 00098 * Success: Pointer to a string containing the error description. 00099 * Failure: NULL 00100 * 00101 * NOTES 00102 * The returned string is statically allocated, you must not 00103 * free this string. 00104 */ 00105 PWCHAR CDECL ldap_err2stringW( ULONG err ) 00106 { 00107 static WCHAR buf[256] = { 0 }; 00108 00109 TRACE( "(0x%08x)\n", err ); 00110 00111 if (err <= WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED) 00112 LoadStringW( hwldap32, err, buf, 256 ); 00113 else 00114 LoadStringW( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 ); 00115 00116 return buf; 00117 } 00118 00119 /*********************************************************************** 00120 * ldap_perror (WLDAP32.@) 00121 * 00122 * Print a given error string. 00123 * 00124 * PARAMS 00125 * ld [I] Pointer to an LDAP context. 00126 * msg [I] Error string. 00127 * 00128 * RETURNS 00129 * Nothing. 00130 * 00131 * NOTES 00132 * Like native, this function does nothing. 00133 */ 00134 void CDECL WLDAP32_ldap_perror( WLDAP32_LDAP *ld, const PCHAR msg ) 00135 { 00136 TRACE( "(%p, %s)\n", ld, debugstr_a(msg) ); 00137 } 00138 00139 /*********************************************************************** 00140 * ldap_result2error (WLDAP32.@) 00141 * 00142 * Parse an LDAP message and return the error obtained from it. 00143 * 00144 * PARAMS 00145 * ld [I] Pointer to an LDAP context. 00146 * res [I] Pointer to an LDAPMessage structure. 00147 * free [I] Ask for the LDAPMessage structure to be freed. 00148 * 00149 * RETURNS 00150 * Success: LDAP_SUCCESS 00151 * Failure: An LDAP error code. 00152 * 00153 * NOTES 00154 * If not asked for, use ldap_msgfree to free the LDAPMessage. 00155 */ 00156 ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free ) 00157 { 00158 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED; 00159 #ifdef HAVE_LDAP 00160 int error; 00161 00162 TRACE( "(%p, %p, 0x%08x)\n", ld, res, free ); 00163 00164 if (!ld || !res) return ~0u; 00165 00166 ret = ldap_parse_result( ld, res, &error, NULL, NULL, NULL, NULL, free ); 00167 00168 if (ret == LDAP_SUCCESS) 00169 ret = error; 00170 else 00171 ret = ~0u; 00172 00173 #endif 00174 return ret; 00175 } 00176 00177 /*********************************************************************** 00178 * LdapGetLastError (WLDAP32.@) 00179 * 00180 * Return the last error set by an LDAP function call. 00181 * 00182 * PARAMS 00183 * None. 00184 * 00185 * RETURNS 00186 * An LDAP error code. 00187 */ 00188 ULONG CDECL LdapGetLastError( void ) 00189 { 00190 TRACE( "\n" ); 00191 return GetLastError(); 00192 } 00193 00194 static const ULONG WLDAP32_errormap[] = { 00195 /* LDAP_SUCCESS */ ERROR_SUCCESS, 00196 /* LDAP_OPERATIONS_ERROR */ ERROR_OPEN_FAILED, 00197 /* LDAP_PROTOCOL_ERROR */ ERROR_INVALID_LEVEL, 00198 /* LDAP_TIMELIMIT_EXCEEDED */ ERROR_TIMEOUT, 00199 /* LDAP_SIZELIMIT_EXCEEDED */ ERROR_MORE_DATA, 00200 /* LDAP_COMPARE_FALSE */ ERROR_DS_GENERIC_ERROR, 00201 /* LDAP_COMPARE_TRUE */ ERROR_DS_GENERIC_ERROR, 00202 /* LDAP_AUTH_METHOD_NOT_SUPPORTED */ ERROR_ACCESS_DENIED, 00203 /* LDAP_STRONG_AUTH_REQUIRED */ ERROR_ACCESS_DENIED, 00204 /* LDAP_REFERRAL_V2 */ ERROR_MORE_DATA, 00205 /* LDAP_REFERRAL */ ERROR_MORE_DATA, 00206 /* LDAP_ADMIN_LIMIT_EXCEEDED */ ERROR_NOT_ENOUGH_QUOTA, 00207 /* LDAP_UNAVAILABLE_CRIT_EXTENSION */ ERROR_CAN_NOT_COMPLETE, 00208 /* LDAP_CONFIDENTIALITY_REQUIRED */ ERROR_DS_GENERIC_ERROR, 00209 /* LDAP_SASL_BIND_IN_PROGRESS */ ERROR_DS_GENERIC_ERROR, 00210 /* 0x0f */ ERROR_DS_GENERIC_ERROR, 00211 /* LDAP_NO_SUCH_ATTRIBUTE */ ERROR_INVALID_PARAMETER, 00212 /* LDAP_UNDEFINED_TYPE */ ERROR_DS_GENERIC_ERROR, 00213 /* LDAP_INAPPROPRIATE_MATCHING */ ERROR_INVALID_PARAMETER, 00214 /* LDAP_CONSTRAINT_VIOLATION */ ERROR_INVALID_PARAMETER, 00215 /* LDAP_ATTRIBUTE_OR_VALUE_EXISTS */ ERROR_ALREADY_EXISTS, 00216 /* LDAP_INVALID_SYNTAX */ ERROR_INVALID_NAME, 00217 /* 0x16 */ ERROR_DS_GENERIC_ERROR, 00218 /* 0x17 */ ERROR_DS_GENERIC_ERROR, 00219 /* 0x18 */ ERROR_DS_GENERIC_ERROR, 00220 /* 0x19 */ ERROR_DS_GENERIC_ERROR, 00221 /* 0x1a */ ERROR_DS_GENERIC_ERROR, 00222 /* 0x1b */ ERROR_DS_GENERIC_ERROR, 00223 /* 0x1c */ ERROR_DS_GENERIC_ERROR, 00224 /* 0x1d */ ERROR_DS_GENERIC_ERROR, 00225 /* 0x1e */ ERROR_DS_GENERIC_ERROR, 00226 /* 0x1f */ ERROR_DS_GENERIC_ERROR, 00227 /* LDAP_NO_SUCH_OBJECT */ ERROR_FILE_NOT_FOUND, 00228 /* LDAP_ALIAS_PROBLEM */ ERROR_DS_GENERIC_ERROR, 00229 /* LDAP_INVALID_DN_SYNTAX */ ERROR_INVALID_PARAMETER, 00230 /* LDAP_IS_LEAF */ ERROR_DS_GENERIC_ERROR, 00231 /* LDAP_ALIAS_DEREF_PROBLEM */ ERROR_DS_GENERIC_ERROR, 00232 /* 0x25 */ ERROR_DS_GENERIC_ERROR, 00233 /* 0x26 */ ERROR_DS_GENERIC_ERROR, 00234 /* 0x27 */ ERROR_DS_GENERIC_ERROR, 00235 /* 0x28 */ ERROR_DS_GENERIC_ERROR, 00236 /* 0x29 */ ERROR_DS_GENERIC_ERROR, 00237 /* 0x2a */ ERROR_DS_GENERIC_ERROR, 00238 /* 0x2b */ ERROR_DS_GENERIC_ERROR, 00239 /* 0x2c */ ERROR_DS_GENERIC_ERROR, 00240 /* 0x2d */ ERROR_DS_GENERIC_ERROR, 00241 /* 0x2e */ ERROR_DS_GENERIC_ERROR, 00242 /* 0x2f */ ERROR_DS_GENERIC_ERROR, 00243 /* LDAP_INAPPROPRIATE_AUTH */ ERROR_ACCESS_DENIED, 00244 /* LDAP_INVALID_CREDENTIALS */ ERROR_WRONG_PASSWORD, 00245 /* LDAP_INSUFFICIENT_RIGHTS */ ERROR_ACCESS_DENIED, 00246 /* LDAP_BUSY */ ERROR_BUSY, 00247 /* LDAP_UNAVAILABLE */ ERROR_DEV_NOT_EXIST, 00248 /* LDAP_UNWILLING_TO_PERFORM */ ERROR_CAN_NOT_COMPLETE, 00249 /* LDAP_LOOP_DETECT */ ERROR_DS_GENERIC_ERROR, 00250 /* 0x37 */ ERROR_DS_GENERIC_ERROR, 00251 /* 0x38 */ ERROR_DS_GENERIC_ERROR, 00252 /* 0x39 */ ERROR_DS_GENERIC_ERROR, 00253 /* 0x3a */ ERROR_DS_GENERIC_ERROR, 00254 /* 0x3b */ ERROR_DS_GENERIC_ERROR, 00255 /* LDAP_SORT_CONTROL_MISSING */ 8261, 00256 /* LDAP_OFFSET_RANGE_ERROR */ 8262, 00257 /* 0x3e */ ERROR_DS_GENERIC_ERROR, 00258 /* 0x3f */ ERROR_DS_GENERIC_ERROR, 00259 /* LDAP_NAMING_VIOLATION */ ERROR_INVALID_PARAMETER, 00260 /* LDAP_OBJECT_CLASS_VIOLATION */ ERROR_INVALID_PARAMETER, 00261 /* LDAP_NOT_ALLOWED_ON_NONLEAF */ ERROR_CAN_NOT_COMPLETE, 00262 /* LDAP_NOT_ALLOWED_ON_RDN */ ERROR_ACCESS_DENIED, 00263 /* LDAP_ALREADY_EXISTS */ ERROR_ALREADY_EXISTS, 00264 /* LDAP_NO_OBJECT_CLASS_MODS */ ERROR_ACCESS_DENIED, 00265 /* LDAP_RESULTS_TOO_LARGE */ ERROR_INSUFFICIENT_BUFFER, 00266 /* LDAP_AFFECTS_MULTIPLE_DSAS */ ERROR_CAN_NOT_COMPLETE, 00267 /* 0x48 */ ERROR_DS_GENERIC_ERROR, 00268 /* 0x49 */ ERROR_DS_GENERIC_ERROR, 00269 /* 0x4a */ ERROR_DS_GENERIC_ERROR, 00270 /* 0x4b */ ERROR_DS_GENERIC_ERROR, 00271 /* LDAP_VIRTUAL_LIST_VIEW_ERROR */ ERROR_DS_GENERIC_ERROR, 00272 /* 0x4d */ ERROR_DS_GENERIC_ERROR, 00273 /* 0x4e */ ERROR_DS_GENERIC_ERROR, 00274 /* 0x4f */ ERROR_DS_GENERIC_ERROR, 00275 /* LDAP_OTHER */ ERROR_DS_GENERIC_ERROR, 00276 /* LDAP_SERVER_DOWN */ ERROR_BAD_NET_RESP, 00277 /* LDAP_LOCAL_ERROR */ ERROR_DS_GENERIC_ERROR, 00278 /* LDAP_ENCODING_ERROR */ ERROR_UNEXP_NET_ERR, 00279 /* LDAP_DECODING_ERROR */ ERROR_UNEXP_NET_ERR, 00280 /* LDAP_TIMEOUT */ ERROR_SERVICE_REQUEST_TIMEOUT, 00281 /* LDAP_AUTH_UNKNOWN */ ERROR_WRONG_PASSWORD, 00282 /* LDAP_FILTER_ERROR */ ERROR_INVALID_PARAMETER, 00283 /* LDAP_USER_CANCELLED */ ERROR_CANCELLED, 00284 /* LDAP_PARAM_ERROR */ ERROR_INVALID_PARAMETER, 00285 /* LDAP_NO_MEMORY */ ERROR_NOT_ENOUGH_MEMORY, 00286 /* LDAP_CONNECT_ERROR */ ERROR_CONNECTION_REFUSED, 00287 /* LDAP_NOT_SUPPORTED */ ERROR_CAN_NOT_COMPLETE, 00288 /* LDAP_CONTROL_NOT_FOUND */ ERROR_NOT_FOUND, 00289 /* LDAP_NO_RESULTS_RETURNED */ ERROR_MORE_DATA, 00290 /* LDAP_MORE_RESULTS_TO_RETURN */ ERROR_MORE_DATA, 00291 /* LDAP_CLIENT_LOOP */ ERROR_DS_GENERIC_ERROR, 00292 /* LDAP_REFERRAL_LIMIT_EXCEEDED */ ERROR_DS_GENERIC_ERROR 00293 }; 00294 00295 /*********************************************************************** 00296 * LdapMapErrorToWin32 (WLDAP32.@) 00297 * 00298 * Map an LDAP error code to a Win32 error code. 00299 * 00300 * PARAMS 00301 * err [I] An LDAP error code. 00302 * 00303 * RETURNS 00304 * A Win32 error code. 00305 */ 00306 ULONG CDECL LdapMapErrorToWin32( ULONG err ) 00307 { 00308 TRACE( "(0x%08x)\n", err ); 00309 00310 if (err >= sizeof(WLDAP32_errormap)/sizeof(WLDAP32_errormap[0])) 00311 return ERROR_DS_GENERIC_ERROR; 00312 return WLDAP32_errormap[err]; 00313 } Generated on Sat May 26 2012 04:16:23 for ReactOS by
1.7.6.1
|