Remove tempfile used to download Mozilla ActiveX control once it's not
[wine/testsucceed.git] / dlls / wldap32 / error.c
blob7efc20685941c161c843b652d71188d732242a27
1 /*
2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "winnls.h"
33 #ifdef HAVE_LDAP_H
34 #include <ldap.h>
35 #else
36 #define LDAP_SUCCESS 0x00
37 #define LDAP_NOT_SUPPORTED 0x5c
38 #endif
40 #include "winldap_private.h"
41 #include "wldap32.h"
43 extern HINSTANCE hwldap32;
45 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
47 PCHAR ldap_err2stringA( ULONG err )
49 static char buf[256] = "";
51 TRACE( "(0x%08lx)\n", err );
53 if (err <= WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED)
54 LoadStringA( hwldap32, err, buf, 256 );
55 else
56 LoadStringA( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 );
58 return buf;
61 PWCHAR ldap_err2stringW( ULONG err )
63 static WCHAR buf[256] = { 0 };
65 TRACE( "(0x%08lx)\n", err );
67 if (err <= WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED)
68 LoadStringW( hwldap32, err, buf, 256 );
69 else
70 LoadStringW( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 );
72 return buf;
76 * NOTES: does nothing
78 void WLDAP32_ldap_perror( WLDAP32_LDAP *ld, const PCHAR msg )
80 TRACE( "(%p, %s)\n", ld, debugstr_a(msg) );
83 ULONG WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free )
85 ULONG ret = LDAP_NOT_SUPPORTED;
86 #ifdef HAVE_LDAP
88 TRACE( "(%p, %p, 0x%08lx)\n", ld, res, free );
90 if (!ld) return ~0UL;
91 ret = ldap_result2error( ld, res, free );
93 #endif
94 return ret;
97 ULONG LdapGetLastError( void )
99 TRACE( "\n" );
100 return GetLastError();
103 static const ULONG WLDAP32_errormap[] = {
104 /* LDAP_SUCCESS */ ERROR_SUCCESS,
105 /* LDAP_OPERATIONS_ERROR */ ERROR_OPEN_FAILED,
106 /* LDAP_PROTOCOL_ERROR */ ERROR_INVALID_LEVEL,
107 /* LDAP_TIMELIMIT_EXCEEDED */ ERROR_TIMEOUT,
108 /* LDAP_SIZELIMIT_EXCEEDED */ ERROR_MORE_DATA,
109 /* LDAP_COMPARE_FALSE */ ERROR_DS_GENERIC_ERROR,
110 /* LDAP_COMPARE_TRUE */ ERROR_DS_GENERIC_ERROR,
111 /* LDAP_AUTH_METHOD_NOT_SUPPORTED */ ERROR_ACCESS_DENIED,
112 /* LDAP_STRONG_AUTH_REQUIRED */ ERROR_ACCESS_DENIED,
113 /* LDAP_REFERRAL_V2 */ ERROR_MORE_DATA,
114 /* LDAP_REFERRAL */ ERROR_MORE_DATA,
115 /* LDAP_ADMIN_LIMIT_EXCEEDED */ ERROR_NOT_ENOUGH_QUOTA,
116 /* LDAP_UNAVAILABLE_CRIT_EXTENSION */ ERROR_CAN_NOT_COMPLETE,
117 /* LDAP_CONFIDENTIALITY_REQUIRED */ ERROR_DS_GENERIC_ERROR,
118 /* LDAP_SASL_BIND_IN_PROGRESS */ ERROR_DS_GENERIC_ERROR,
119 /* 0x0f */ ERROR_DS_GENERIC_ERROR,
120 /* LDAP_NO_SUCH_ATTRIBUTE */ ERROR_INVALID_PARAMETER,
121 /* LDAP_UNDEFINED_TYPE */ ERROR_DS_GENERIC_ERROR,
122 /* LDAP_INAPPROPRIATE_MATCHING */ ERROR_INVALID_PARAMETER,
123 /* LDAP_CONSTRAINT_VIOLATION */ ERROR_INVALID_PARAMETER,
124 /* LDAP_ATTRIBUTE_OR_VALUE_EXISTS */ ERROR_ALREADY_EXISTS,
125 /* LDAP_INVALID_SYNTAX */ ERROR_INVALID_NAME,
126 /* 0x16 */ ERROR_DS_GENERIC_ERROR,
127 /* 0x17 */ ERROR_DS_GENERIC_ERROR,
128 /* 0x18 */ ERROR_DS_GENERIC_ERROR,
129 /* 0x19 */ ERROR_DS_GENERIC_ERROR,
130 /* 0x1a */ ERROR_DS_GENERIC_ERROR,
131 /* 0x1b */ ERROR_DS_GENERIC_ERROR,
132 /* 0x1c */ ERROR_DS_GENERIC_ERROR,
133 /* 0x1d */ ERROR_DS_GENERIC_ERROR,
134 /* 0x1e */ ERROR_DS_GENERIC_ERROR,
135 /* 0x1f */ ERROR_DS_GENERIC_ERROR,
136 /* LDAP_NO_SUCH_OBJECT */ ERROR_FILE_NOT_FOUND,
137 /* LDAP_ALIAS_PROBLEM */ ERROR_DS_GENERIC_ERROR,
138 /* LDAP_INVALID_DN_SYNTAX */ ERROR_INVALID_PARAMETER,
139 /* LDAP_IS_LEAF */ ERROR_DS_GENERIC_ERROR,
140 /* LDAP_ALIAS_DEREF_PROBLEM */ ERROR_DS_GENERIC_ERROR,
141 /* 0x25 */ ERROR_DS_GENERIC_ERROR,
142 /* 0x26 */ ERROR_DS_GENERIC_ERROR,
143 /* 0x27 */ ERROR_DS_GENERIC_ERROR,
144 /* 0x28 */ ERROR_DS_GENERIC_ERROR,
145 /* 0x29 */ ERROR_DS_GENERIC_ERROR,
146 /* 0x2a */ ERROR_DS_GENERIC_ERROR,
147 /* 0x2b */ ERROR_DS_GENERIC_ERROR,
148 /* 0x2c */ ERROR_DS_GENERIC_ERROR,
149 /* 0x2d */ ERROR_DS_GENERIC_ERROR,
150 /* 0x2e */ ERROR_DS_GENERIC_ERROR,
151 /* 0x2f */ ERROR_DS_GENERIC_ERROR,
152 /* LDAP_INAPPROPRIATE_AUTH */ ERROR_ACCESS_DENIED,
153 /* LDAP_INVALID_CREDENTIALS */ ERROR_WRONG_PASSWORD,
154 /* LDAP_INSUFFICIENT_RIGHTS */ ERROR_ACCESS_DENIED,
155 /* LDAP_BUSY */ ERROR_BUSY,
156 /* LDAP_UNAVAILABLE */ ERROR_DEV_NOT_EXIST,
157 /* LDAP_UNWILLING_TO_PERFORM */ ERROR_CAN_NOT_COMPLETE,
158 /* LDAP_LOOP_DETECT */ ERROR_DS_GENERIC_ERROR,
159 /* 0x37 */ ERROR_DS_GENERIC_ERROR,
160 /* 0x38 */ ERROR_DS_GENERIC_ERROR,
161 /* 0x39 */ ERROR_DS_GENERIC_ERROR,
162 /* 0x3a */ ERROR_DS_GENERIC_ERROR,
163 /* 0x3b */ ERROR_DS_GENERIC_ERROR,
164 /* LDAP_SORT_CONTROL_MISSING */ 8261,
165 /* LDAP_OFFSET_RANGE_ERROR */ 8262,
166 /* 0x3e */ ERROR_DS_GENERIC_ERROR,
167 /* 0x3f */ ERROR_DS_GENERIC_ERROR,
168 /* LDAP_NAMING_VIOLATION */ ERROR_INVALID_PARAMETER,
169 /* LDAP_OBJECT_CLASS_VIOLATION */ ERROR_INVALID_PARAMETER,
170 /* LDAP_NOT_ALLOWED_ON_NONLEAF */ ERROR_CAN_NOT_COMPLETE,
171 /* LDAP_NOT_ALLOWED_ON_RDN */ ERROR_ACCESS_DENIED,
172 /* LDAP_ALREADY_EXISTS */ ERROR_ALREADY_EXISTS,
173 /* LDAP_NO_OBJECT_CLASS_MODS */ ERROR_ACCESS_DENIED,
174 /* LDAP_RESULTS_TOO_LARGE */ ERROR_INSUFFICIENT_BUFFER,
175 /* LDAP_AFFECTS_MULTIPLE_DSAS */ ERROR_CAN_NOT_COMPLETE,
176 /* 0x48 */ ERROR_DS_GENERIC_ERROR,
177 /* 0x49 */ ERROR_DS_GENERIC_ERROR,
178 /* 0x4a */ ERROR_DS_GENERIC_ERROR,
179 /* 0x4b */ ERROR_DS_GENERIC_ERROR,
180 /* LDAP_VIRTUAL_LIST_VIEW_ERROR */ ERROR_DS_GENERIC_ERROR,
181 /* 0x4d */ ERROR_DS_GENERIC_ERROR,
182 /* 0x4e */ ERROR_DS_GENERIC_ERROR,
183 /* 0x4f */ ERROR_DS_GENERIC_ERROR,
184 /* LDAP_OTHER */ ERROR_DS_GENERIC_ERROR,
185 /* LDAP_SERVER_DOWN */ ERROR_BAD_NET_RESP,
186 /* LDAP_LOCAL_ERROR */ ERROR_DS_GENERIC_ERROR,
187 /* LDAP_ENCODING_ERROR */ ERROR_UNEXP_NET_ERR,
188 /* LDAP_DECODING_ERROR */ ERROR_UNEXP_NET_ERR,
189 /* LDAP_TIMEOUT */ ERROR_SERVICE_REQUEST_TIMEOUT,
190 /* LDAP_AUTH_UNKNOWN */ ERROR_WRONG_PASSWORD,
191 /* LDAP_FILTER_ERROR */ ERROR_INVALID_PARAMETER,
192 /* LDAP_USER_CANCELLED */ ERROR_CANCELLED,
193 /* LDAP_PARAM_ERROR */ ERROR_INVALID_PARAMETER,
194 /* LDAP_NO_MEMORY */ ERROR_NOT_ENOUGH_MEMORY,
195 /* LDAP_CONNECT_ERROR */ ERROR_CONNECTION_REFUSED,
196 /* LDAP_NOT_SUPPORTED */ ERROR_CAN_NOT_COMPLETE,
197 /* LDAP_CONTROL_NOT_FOUND */ ERROR_NOT_FOUND,
198 /* LDAP_NO_RESULTS_RETURNED */ ERROR_MORE_DATA,
199 /* LDAP_MORE_RESULTS_TO_RETURN */ ERROR_MORE_DATA,
200 /* LDAP_CLIENT_LOOP */ ERROR_DS_GENERIC_ERROR,
201 /* LDAP_REFERRAL_LIMIT_EXCEEDED */ ERROR_DS_GENERIC_ERROR
204 ULONG LdapMapErrorToWin32( ULONG err )
206 TRACE( "(0x%08lx)\n", err );
208 if (err > sizeof(WLDAP32_errormap)/sizeof(WLDAP32_errormap[0]))
209 return ERROR_DS_GENERIC_ERROR;
210 return WLDAP32_errormap[err];