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
23 #include "wine/port.h"
24 #include "wine/debug.h"
36 #define LDAP_SUCCESS 0x00
37 #define LDAP_NOT_SUPPORTED 0x5c
40 #include "winldap_private.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 );
56 LoadStringA( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 );
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 );
70 LoadStringW( hwldap32, WLDAP32_LDAP_LOCAL_ERROR, buf, 256 );
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;
88 TRACE( "(%p, %p, 0x%08lx)\n", ld, res, free );
91 ret = ldap_result2error( ld, res, free );
97 static const ULONG WLDAP32_errormap[] = {
98 /* LDAP_SUCCESS */ ERROR_SUCCESS,
99 /* LDAP_OPERATIONS_ERROR */ ERROR_OPEN_FAILED,
100 /* LDAP_PROTOCOL_ERROR */ ERROR_INVALID_LEVEL,
101 /* LDAP_TIMELIMIT_EXCEEDED */ ERROR_TIMEOUT,
102 /* LDAP_SIZELIMIT_EXCEEDED */ ERROR_MORE_DATA,
103 /* LDAP_COMPARE_FALSE */ ERROR_DS_GENERIC_ERROR,
104 /* LDAP_COMPARE_TRUE */ ERROR_DS_GENERIC_ERROR,
105 /* LDAP_AUTH_METHOD_NOT_SUPPORTED */ ERROR_ACCESS_DENIED,
106 /* LDAP_STRONG_AUTH_REQUIRED */ ERROR_ACCESS_DENIED,
107 /* LDAP_REFERRAL_V2 */ ERROR_MORE_DATA,
108 /* LDAP_REFERRAL */ ERROR_MORE_DATA,
109 /* LDAP_ADMIN_LIMIT_EXCEEDED */ ERROR_NOT_ENOUGH_QUOTA,
110 /* LDAP_UNAVAILABLE_CRIT_EXTENSION */ ERROR_CAN_NOT_COMPLETE,
111 /* LDAP_CONFIDENTIALITY_REQUIRED */ ERROR_DS_GENERIC_ERROR,
112 /* LDAP_SASL_BIND_IN_PROGRESS */ ERROR_DS_GENERIC_ERROR,
113 /* 0x0f */ ERROR_DS_GENERIC_ERROR,
114 /* LDAP_NO_SUCH_ATTRIBUTE */ ERROR_INVALID_PARAMETER,
115 /* LDAP_UNDEFINED_TYPE */ ERROR_DS_GENERIC_ERROR,
116 /* LDAP_INAPPROPRIATE_MATCHING */ ERROR_INVALID_PARAMETER,
117 /* LDAP_CONSTRAINT_VIOLATION */ ERROR_INVALID_PARAMETER,
118 /* LDAP_ATTRIBUTE_OR_VALUE_EXISTS */ ERROR_ALREADY_EXISTS,
119 /* LDAP_INVALID_SYNTAX */ ERROR_INVALID_NAME,
120 /* 0x16 */ ERROR_DS_GENERIC_ERROR,
121 /* 0x17 */ ERROR_DS_GENERIC_ERROR,
122 /* 0x18 */ ERROR_DS_GENERIC_ERROR,
123 /* 0x19 */ ERROR_DS_GENERIC_ERROR,
124 /* 0x1a */ ERROR_DS_GENERIC_ERROR,
125 /* 0x1b */ ERROR_DS_GENERIC_ERROR,
126 /* 0x1c */ ERROR_DS_GENERIC_ERROR,
127 /* 0x1d */ ERROR_DS_GENERIC_ERROR,
128 /* 0x1e */ ERROR_DS_GENERIC_ERROR,
129 /* 0x1f */ ERROR_DS_GENERIC_ERROR,
130 /* LDAP_NO_SUCH_OBJECT */ ERROR_FILE_NOT_FOUND,
131 /* LDAP_ALIAS_PROBLEM */ ERROR_DS_GENERIC_ERROR,
132 /* LDAP_INVALID_DN_SYNTAX */ ERROR_INVALID_PARAMETER,
133 /* LDAP_IS_LEAF */ ERROR_DS_GENERIC_ERROR,
134 /* LDAP_ALIAS_DEREF_PROBLEM */ ERROR_DS_GENERIC_ERROR,
135 /* 0x25 */ ERROR_DS_GENERIC_ERROR,
136 /* 0x26 */ ERROR_DS_GENERIC_ERROR,
137 /* 0x27 */ ERROR_DS_GENERIC_ERROR,
138 /* 0x28 */ ERROR_DS_GENERIC_ERROR,
139 /* 0x29 */ ERROR_DS_GENERIC_ERROR,
140 /* 0x2a */ ERROR_DS_GENERIC_ERROR,
141 /* 0x2b */ ERROR_DS_GENERIC_ERROR,
142 /* 0x2c */ ERROR_DS_GENERIC_ERROR,
143 /* 0x2d */ ERROR_DS_GENERIC_ERROR,
144 /* 0x2e */ ERROR_DS_GENERIC_ERROR,
145 /* 0x2f */ ERROR_DS_GENERIC_ERROR,
146 /* LDAP_INAPPROPRIATE_AUTH */ ERROR_ACCESS_DENIED,
147 /* LDAP_INVALID_CREDENTIALS */ ERROR_WRONG_PASSWORD,
148 /* LDAP_INSUFFICIENT_RIGHTS */ ERROR_ACCESS_DENIED,
149 /* LDAP_BUSY */ ERROR_BUSY,
150 /* LDAP_UNAVAILABLE */ ERROR_DEV_NOT_EXIST,
151 /* LDAP_UNWILLING_TO_PERFORM */ ERROR_CAN_NOT_COMPLETE,
152 /* LDAP_LOOP_DETECT */ ERROR_DS_GENERIC_ERROR,
153 /* 0x37 */ ERROR_DS_GENERIC_ERROR,
154 /* 0x38 */ ERROR_DS_GENERIC_ERROR,
155 /* 0x39 */ ERROR_DS_GENERIC_ERROR,
156 /* 0x3a */ ERROR_DS_GENERIC_ERROR,
157 /* 0x3b */ ERROR_DS_GENERIC_ERROR,
158 /* LDAP_SORT_CONTROL_MISSING */ 8261,
159 /* LDAP_OFFSET_RANGE_ERROR */ 8262,
160 /* 0x3e */ ERROR_DS_GENERIC_ERROR,
161 /* 0x3f */ ERROR_DS_GENERIC_ERROR,
162 /* LDAP_NAMING_VIOLATION */ ERROR_INVALID_PARAMETER,
163 /* LDAP_OBJECT_CLASS_VIOLATION */ ERROR_INVALID_PARAMETER,
164 /* LDAP_NOT_ALLOWED_ON_NONLEAF */ ERROR_CAN_NOT_COMPLETE,
165 /* LDAP_NOT_ALLOWED_ON_RDN */ ERROR_ACCESS_DENIED,
166 /* LDAP_ALREADY_EXISTS */ ERROR_ALREADY_EXISTS,
167 /* LDAP_NO_OBJECT_CLASS_MODS */ ERROR_ACCESS_DENIED,
168 /* LDAP_RESULTS_TOO_LARGE */ ERROR_INSUFFICIENT_BUFFER,
169 /* LDAP_AFFECTS_MULTIPLE_DSAS */ ERROR_CAN_NOT_COMPLETE,
170 /* 0x48 */ ERROR_DS_GENERIC_ERROR,
171 /* 0x49 */ ERROR_DS_GENERIC_ERROR,
172 /* 0x4a */ ERROR_DS_GENERIC_ERROR,
173 /* 0x4b */ ERROR_DS_GENERIC_ERROR,
174 /* LDAP_VIRTUAL_LIST_VIEW_ERROR */ ERROR_DS_GENERIC_ERROR,
175 /* 0x4d */ ERROR_DS_GENERIC_ERROR,
176 /* 0x4e */ ERROR_DS_GENERIC_ERROR,
177 /* 0x4f */ ERROR_DS_GENERIC_ERROR,
178 /* LDAP_OTHER */ ERROR_DS_GENERIC_ERROR,
179 /* LDAP_SERVER_DOWN */ ERROR_BAD_NET_RESP,
180 /* LDAP_LOCAL_ERROR */ ERROR_DS_GENERIC_ERROR,
181 /* LDAP_ENCODING_ERROR */ ERROR_UNEXP_NET_ERR,
182 /* LDAP_DECODING_ERROR */ ERROR_UNEXP_NET_ERR,
183 /* LDAP_TIMEOUT */ ERROR_SERVICE_REQUEST_TIMEOUT,
184 /* LDAP_AUTH_UNKNOWN */ ERROR_WRONG_PASSWORD,
185 /* LDAP_FILTER_ERROR */ ERROR_INVALID_PARAMETER,
186 /* LDAP_USER_CANCELLED */ ERROR_CANCELLED,
187 /* LDAP_PARAM_ERROR */ ERROR_INVALID_PARAMETER,
188 /* LDAP_NO_MEMORY */ ERROR_NOT_ENOUGH_MEMORY,
189 /* LDAP_CONNECT_ERROR */ ERROR_CONNECTION_REFUSED,
190 /* LDAP_NOT_SUPPORTED */ ERROR_CAN_NOT_COMPLETE,
191 /* LDAP_CONTROL_NOT_FOUND */ ERROR_NOT_FOUND,
192 /* LDAP_NO_RESULTS_RETURNED */ ERROR_MORE_DATA,
193 /* LDAP_MORE_RESULTS_TO_RETURN */ ERROR_MORE_DATA,
194 /* LDAP_CLIENT_LOOP */ ERROR_DS_GENERIC_ERROR,
195 /* LDAP_REFERRAL_LIMIT_EXCEEDED */ ERROR_DS_GENERIC_ERROR
198 ULONG LdapMapErrorToWin32( ULONG err )
200 TRACE( "(0x%08lx)\n", err );
202 if (err > sizeof(WLDAP32_errormap)/sizeof(WLDAP32_errormap[0]))
203 return ERROR_DS_GENERIC_ERROR;
204 return WLDAP32_errormap[err];