ReactOS 0.4.15-dev-7924-g5949c20
error.c
Go to the documentation of this file.
1/*
2 * WLDAP32 - LDAP support for Wine
3 *
4 * Copyright 2005 Hans Leidekker
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "config.h"
22#include "wine/port.h"
23
24#include <stdarg.h>
25#ifdef HAVE_LDAP_H
26#include <ldap.h>
27#endif
28
29#include "windef.h"
30#include "winbase.h"
31#include "winuser.h"
32#include "winnls.h"
33
34#include "winldap_private.h"
35#include "wldap32.h"
36#include "wine/debug.h"
37
39
41{
42 switch (error)
43 {
44#ifdef HAVE_LDAP_H
61#endif
62 default: return error;
63 }
64}
65
66/***********************************************************************
67 * ldap_err2stringA (WLDAP32.@)
68 *
69 * See ldap_err2stringW.
70 */
72{
73 static char buf[256] = "";
74
75 TRACE( "(0x%08x)\n", err );
76
78 LoadStringA( hwldap32, err, buf, 256 );
79 else
81
82 return buf;
83}
84
85/***********************************************************************
86 * ldap_err2stringW (WLDAP32.@)
87 *
88 * Convert an error code into a string describing the error.
89 *
90 * PARAMS
91 * err [I] Error code to convert.
92 *
93 * RETURNS
94 * Success: Pointer to a string containing the error description.
95 * Failure: NULL
96 *
97 * NOTES
98 * The returned string is statically allocated, you must not
99 * free this string.
100 */
102{
103 static WCHAR buf[256] = { 0 };
104
105 TRACE( "(0x%08x)\n", err );
106
108 LoadStringW( hwldap32, err, buf, 256 );
109 else
111
112 return buf;
113}
114
115/***********************************************************************
116 * ldap_perror (WLDAP32.@)
117 *
118 * Print a given error string.
119 *
120 * PARAMS
121 * ld [I] Pointer to an LDAP context.
122 * msg [I] Error string.
123 *
124 * RETURNS
125 * Nothing.
126 *
127 * NOTES
128 * Like native, this function does nothing.
129 */
131{
132 TRACE( "(%p, %s)\n", ld, debugstr_a(msg) );
133}
134
135/***********************************************************************
136 * ldap_result2error (WLDAP32.@)
137 *
138 * Parse an LDAP message and return the error obtained from it.
139 *
140 * PARAMS
141 * ld [I] Pointer to an LDAP context.
142 * res [I] Pointer to an LDAPMessage structure.
143 * free [I] Ask for the LDAPMessage structure to be freed.
144 *
145 * RETURNS
146 * Success: LDAP_SUCCESS
147 * Failure: An LDAP error code.
148 *
149 * NOTES
150 * If not asked for, use ldap_msgfree to free the LDAPMessage.
151 */
153{
155#ifdef HAVE_LDAP
156 int error;
157
158 TRACE( "(%p, %p, 0x%08x)\n", ld, res, free );
159
160 if (!ld || !res) return ~0u;
161
163
164 if (ret == LDAP_SUCCESS)
165 ret = error;
166 else
167 ret = ~0u;
168
169#endif
170 return ret;
171}
172
173/***********************************************************************
174 * LdapGetLastError (WLDAP32.@)
175 *
176 * Return the last error set by an LDAP function call.
177 *
178 * PARAMS
179 * None.
180 *
181 * RETURNS
182 * An LDAP error code.
183 */
185{
186 TRACE( "\n" );
187 return GetLastError();
188}
189
190static const ULONG WLDAP32_errormap[] = {
191 /* LDAP_SUCCESS */ ERROR_SUCCESS,
192 /* LDAP_OPERATIONS_ERROR */ ERROR_OPEN_FAILED,
193 /* LDAP_PROTOCOL_ERROR */ ERROR_INVALID_LEVEL,
194 /* LDAP_TIMELIMIT_EXCEEDED */ ERROR_TIMEOUT,
195 /* LDAP_SIZELIMIT_EXCEEDED */ ERROR_MORE_DATA,
196 /* LDAP_COMPARE_FALSE */ ERROR_DS_GENERIC_ERROR,
197 /* LDAP_COMPARE_TRUE */ ERROR_DS_GENERIC_ERROR,
198 /* LDAP_AUTH_METHOD_NOT_SUPPORTED */ ERROR_ACCESS_DENIED,
199 /* LDAP_STRONG_AUTH_REQUIRED */ ERROR_ACCESS_DENIED,
200 /* LDAP_REFERRAL_V2 */ ERROR_MORE_DATA,
201 /* LDAP_REFERRAL */ ERROR_MORE_DATA,
202 /* LDAP_ADMIN_LIMIT_EXCEEDED */ ERROR_NOT_ENOUGH_QUOTA,
203 /* LDAP_UNAVAILABLE_CRIT_EXTENSION */ ERROR_CAN_NOT_COMPLETE,
204 /* LDAP_CONFIDENTIALITY_REQUIRED */ ERROR_DS_GENERIC_ERROR,
205 /* LDAP_SASL_BIND_IN_PROGRESS */ ERROR_DS_GENERIC_ERROR,
206 /* 0x0f */ ERROR_DS_GENERIC_ERROR,
207 /* LDAP_NO_SUCH_ATTRIBUTE */ ERROR_INVALID_PARAMETER,
208 /* LDAP_UNDEFINED_TYPE */ ERROR_DS_GENERIC_ERROR,
209 /* LDAP_INAPPROPRIATE_MATCHING */ ERROR_INVALID_PARAMETER,
210 /* LDAP_CONSTRAINT_VIOLATION */ ERROR_INVALID_PARAMETER,
211 /* LDAP_ATTRIBUTE_OR_VALUE_EXISTS */ ERROR_ALREADY_EXISTS,
212 /* LDAP_INVALID_SYNTAX */ ERROR_INVALID_NAME,
213 /* 0x16 */ ERROR_DS_GENERIC_ERROR,
214 /* 0x17 */ ERROR_DS_GENERIC_ERROR,
215 /* 0x18 */ ERROR_DS_GENERIC_ERROR,
216 /* 0x19 */ ERROR_DS_GENERIC_ERROR,
217 /* 0x1a */ ERROR_DS_GENERIC_ERROR,
218 /* 0x1b */ ERROR_DS_GENERIC_ERROR,
219 /* 0x1c */ ERROR_DS_GENERIC_ERROR,
220 /* 0x1d */ ERROR_DS_GENERIC_ERROR,
221 /* 0x1e */ ERROR_DS_GENERIC_ERROR,
222 /* 0x1f */ ERROR_DS_GENERIC_ERROR,
223 /* LDAP_NO_SUCH_OBJECT */ ERROR_FILE_NOT_FOUND,
224 /* LDAP_ALIAS_PROBLEM */ ERROR_DS_GENERIC_ERROR,
225 /* LDAP_INVALID_DN_SYNTAX */ ERROR_INVALID_PARAMETER,
226 /* LDAP_IS_LEAF */ ERROR_DS_GENERIC_ERROR,
227 /* LDAP_ALIAS_DEREF_PROBLEM */ ERROR_DS_GENERIC_ERROR,
228 /* 0x25 */ ERROR_DS_GENERIC_ERROR,
229 /* 0x26 */ ERROR_DS_GENERIC_ERROR,
230 /* 0x27 */ ERROR_DS_GENERIC_ERROR,
231 /* 0x28 */ ERROR_DS_GENERIC_ERROR,
232 /* 0x29 */ ERROR_DS_GENERIC_ERROR,
233 /* 0x2a */ ERROR_DS_GENERIC_ERROR,
234 /* 0x2b */ ERROR_DS_GENERIC_ERROR,
235 /* 0x2c */ ERROR_DS_GENERIC_ERROR,
236 /* 0x2d */ ERROR_DS_GENERIC_ERROR,
237 /* 0x2e */ ERROR_DS_GENERIC_ERROR,
238 /* 0x2f */ ERROR_DS_GENERIC_ERROR,
239 /* LDAP_INAPPROPRIATE_AUTH */ ERROR_ACCESS_DENIED,
240 /* LDAP_INVALID_CREDENTIALS */ ERROR_WRONG_PASSWORD,
241 /* LDAP_INSUFFICIENT_RIGHTS */ ERROR_ACCESS_DENIED,
242 /* LDAP_BUSY */ ERROR_BUSY,
243 /* LDAP_UNAVAILABLE */ ERROR_DEV_NOT_EXIST,
244 /* LDAP_UNWILLING_TO_PERFORM */ ERROR_CAN_NOT_COMPLETE,
245 /* LDAP_LOOP_DETECT */ ERROR_DS_GENERIC_ERROR,
246 /* 0x37 */ ERROR_DS_GENERIC_ERROR,
247 /* 0x38 */ ERROR_DS_GENERIC_ERROR,
248 /* 0x39 */ ERROR_DS_GENERIC_ERROR,
249 /* 0x3a */ ERROR_DS_GENERIC_ERROR,
250 /* 0x3b */ ERROR_DS_GENERIC_ERROR,
251 /* LDAP_SORT_CONTROL_MISSING */ 8261,
252 /* LDAP_OFFSET_RANGE_ERROR */ 8262,
253 /* 0x3e */ ERROR_DS_GENERIC_ERROR,
254 /* 0x3f */ ERROR_DS_GENERIC_ERROR,
255 /* LDAP_NAMING_VIOLATION */ ERROR_INVALID_PARAMETER,
256 /* LDAP_OBJECT_CLASS_VIOLATION */ ERROR_INVALID_PARAMETER,
257 /* LDAP_NOT_ALLOWED_ON_NONLEAF */ ERROR_CAN_NOT_COMPLETE,
258 /* LDAP_NOT_ALLOWED_ON_RDN */ ERROR_ACCESS_DENIED,
259 /* LDAP_ALREADY_EXISTS */ ERROR_ALREADY_EXISTS,
260 /* LDAP_NO_OBJECT_CLASS_MODS */ ERROR_ACCESS_DENIED,
261 /* LDAP_RESULTS_TOO_LARGE */ ERROR_INSUFFICIENT_BUFFER,
262 /* LDAP_AFFECTS_MULTIPLE_DSAS */ ERROR_CAN_NOT_COMPLETE,
263 /* 0x48 */ ERROR_DS_GENERIC_ERROR,
264 /* 0x49 */ ERROR_DS_GENERIC_ERROR,
265 /* 0x4a */ ERROR_DS_GENERIC_ERROR,
266 /* 0x4b */ ERROR_DS_GENERIC_ERROR,
267 /* LDAP_VIRTUAL_LIST_VIEW_ERROR */ ERROR_DS_GENERIC_ERROR,
268 /* 0x4d */ ERROR_DS_GENERIC_ERROR,
269 /* 0x4e */ ERROR_DS_GENERIC_ERROR,
270 /* 0x4f */ ERROR_DS_GENERIC_ERROR,
271 /* LDAP_OTHER */ ERROR_DS_GENERIC_ERROR,
272 /* LDAP_SERVER_DOWN */ ERROR_BAD_NET_RESP,
273 /* LDAP_LOCAL_ERROR */ ERROR_DS_GENERIC_ERROR,
274 /* LDAP_ENCODING_ERROR */ ERROR_UNEXP_NET_ERR,
275 /* LDAP_DECODING_ERROR */ ERROR_UNEXP_NET_ERR,
276 /* LDAP_TIMEOUT */ ERROR_SERVICE_REQUEST_TIMEOUT,
277 /* LDAP_AUTH_UNKNOWN */ ERROR_WRONG_PASSWORD,
278 /* LDAP_FILTER_ERROR */ ERROR_INVALID_PARAMETER,
279 /* LDAP_USER_CANCELLED */ ERROR_CANCELLED,
280 /* LDAP_PARAM_ERROR */ ERROR_INVALID_PARAMETER,
281 /* LDAP_NO_MEMORY */ ERROR_NOT_ENOUGH_MEMORY,
282 /* LDAP_CONNECT_ERROR */ ERROR_CONNECTION_REFUSED,
283 /* LDAP_NOT_SUPPORTED */ ERROR_CAN_NOT_COMPLETE,
284 /* LDAP_CONTROL_NOT_FOUND */ ERROR_NOT_FOUND,
285 /* LDAP_NO_RESULTS_RETURNED */ ERROR_MORE_DATA,
286 /* LDAP_MORE_RESULTS_TO_RETURN */ ERROR_MORE_DATA,
287 /* LDAP_CLIENT_LOOP */ ERROR_DS_GENERIC_ERROR,
288 /* LDAP_REFERRAL_LIMIT_EXCEEDED */ ERROR_DS_GENERIC_ERROR
289};
290
291/***********************************************************************
292 * LdapMapErrorToWin32 (WLDAP32.@)
293 *
294 * Map an LDAP error code to a Win32 error code.
295 *
296 * PARAMS
297 * err [I] An LDAP error code.
298 *
299 * RETURNS
300 * A Win32 error code.
301 */
303{
304 TRACE( "(0x%08x)\n", err );
305
308 return WLDAP32_errormap[err];
309}
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:33
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_BUSY
Definition: dderror.h:12
#define free
Definition: debug_ros.c:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define ERROR_INVALID_NAME
Definition: compat.h:103
PWCHAR CDECL ldap_err2stringW(ULONG err)
Definition: error.c:101
void CDECL WLDAP32_ldap_perror(WLDAP32_LDAP *ld, const PCHAR msg)
Definition: error.c:130
PCHAR CDECL ldap_err2stringA(ULONG err)
Definition: error.c:71
ULONG CDECL WLDAP32_ldap_result2error(WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free)
Definition: error.c:152
ULONG CDECL LdapMapErrorToWin32(ULONG err)
Definition: error.c:302
ULONG CDECL LdapGetLastError(void)
Definition: error.c:184
ULONG map_error(int error)
Definition: error.c:40
static const ULONG WLDAP32_errormap[]
Definition: error.c:190
HINSTANCE hwldap32
Definition: main.c:29
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define debugstr_a
Definition: kernel32.h:31
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define err(...)
#define TRACE(s)
Definition: solgame.cpp:4
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_NOT_ENOUGH_QUOTA
Definition: winerror.h:1123
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define ERROR_OPEN_FAILED
Definition: winerror.h:184
#define ERROR_CONNECTION_REFUSED
Definition: winerror.h:728
#define ERROR_CANCELLED
Definition: winerror.h:726
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
#define ERROR_DS_GENERIC_ERROR
Definition: winerror.h:1575
#define ERROR_UNEXP_NET_ERR
Definition: winerror.h:151
#define ERROR_WRONG_PASSWORD
Definition: winerror.h:805
#define ERROR_TIMEOUT
Definition: winerror.h:941
#define ERROR_SERVICE_REQUEST_TIMEOUT
Definition: winerror.h:604
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define LDAP_SERVER_DOWN
Definition: winldap.h:101
#define LDAP_REFERRAL_LIMIT_EXCEEDED
Definition: winldap.h:117
#define LDAP_MORE_RESULTS_TO_RETURN
Definition: winldap.h:115
#define LDAP_USER_CANCELLED
Definition: winldap.h:108
#define LDAP_DECODING_ERROR
Definition: winldap.h:104
#define LDAP_TIMEOUT
Definition: winldap.h:105
#define LDAP_LOCAL_ERROR
Definition: winldap.h:102
#define LDAP_CLIENT_LOOP
Definition: winldap.h:116
#define ldap_parse_result
Definition: winldap.h:675
#define LDAP_AUTH_UNKNOWN
Definition: winldap.h:106
#define LDAP_SUCCESS
Definition: winldap.h:59
#define LDAP_PARAM_ERROR
Definition: winldap.h:109
#define LDAP_NO_MEMORY
Definition: winldap.h:110
#define LDAP_NO_RESULTS_RETURNED
Definition: winldap.h:114
#define LDAP_CONTROL_NOT_FOUND
Definition: winldap.h:113
#define LDAP_NOT_SUPPORTED
Definition: winldap.h:112
#define LDAP_CONNECT_ERROR
Definition: winldap.h:111
#define LDAP_FILTER_ERROR
Definition: winldap.h:107
@ WLDAP32_LDAP_USER_CANCELLED
@ WLDAP32_LDAP_DECODING_ERROR
@ WLDAP32_LDAP_MORE_RESULTS_TO_RETURN
@ WLDAP32_LDAP_AUTH_UNKNOWN
@ WLDAP32_LDAP_LOCAL_ERROR
@ WLDAP32_LDAP_PARAM_ERROR
@ WLDAP32_LDAP_NOT_SUPPORTED
@ WLDAP32_LDAP_NO_RESULTS_RETURNED
@ WLDAP32_LDAP_NO_MEMORY
@ WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED
@ WLDAP32_LDAP_CLIENT_LOOP
@ WLDAP32_LDAP_FILTER_ERROR
@ WLDAP32_LDAP_SERVER_DOWN
@ WLDAP32_LDAP_TIMEOUT
@ WLDAP32_LDAP_CONTROL_NOT_FOUND
@ WLDAP32_LDAP_CONNECT_ERROR
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180