Change all uses of uint32/16/8 in proto.h to uint32_t/16_t/8_t.
[kamenim/samba-autobuild/.git] / source3 / libsmb / errormap_wbc.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  error mapping functions
4  *  Copyright (C) Andrew Tridgell 2001
5  *  Copyright (C) Andrew Bartlett 2001
6  *  Copyright (C) Tim Potter 2000
7  *  
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 3 of the License, or
11  *  (at your option) any later version.
12  *  
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *  
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #include "includes.h"
23 #include "nsswitch/libwbclient/wbclient.h"
24
25 /*******************************************************************************
26  Map between wbcErr and NT status.
27 *******************************************************************************/
28
29 static const struct {
30         wbcErr wbc_err;
31         NTSTATUS nt_status;
32 } wbcErr_ntstatus_map[] = {
33         { WBC_ERR_SUCCESS,               NT_STATUS_OK },
34         { WBC_ERR_NOT_IMPLEMENTED,       NT_STATUS_NOT_IMPLEMENTED },
35         { WBC_ERR_UNKNOWN_FAILURE,       NT_STATUS_UNSUCCESSFUL },
36         { WBC_ERR_NO_MEMORY,             NT_STATUS_NO_MEMORY },
37         { WBC_ERR_INVALID_SID,           NT_STATUS_INVALID_SID },
38         { WBC_ERR_INVALID_PARAM,         NT_STATUS_INVALID_PARAMETER },
39         { WBC_ERR_WINBIND_NOT_AVAILABLE, NT_STATUS_SERVER_DISABLED },
40         { WBC_ERR_DOMAIN_NOT_FOUND,      NT_STATUS_NO_SUCH_DOMAIN },
41         { WBC_ERR_INVALID_RESPONSE,      NT_STATUS_INVALID_NETWORK_RESPONSE },
42         { WBC_ERR_NSS_ERROR,             NT_STATUS_INTERNAL_ERROR },
43         { WBC_ERR_AUTH_ERROR,            NT_STATUS_LOGON_FAILURE },
44         { WBC_ERR_UNKNOWN_USER,          NT_STATUS_NO_SUCH_USER },
45         { WBC_ERR_UNKNOWN_GROUP,         NT_STATUS_NO_SUCH_GROUP },
46         { WBC_ERR_PWD_CHANGE_FAILED,     NT_STATUS_PASSWORD_RESTRICTION }
47 };
48
49 NTSTATUS map_nt_error_from_wbcErr(wbcErr wbc_err)
50 {
51         int i;
52
53         /* Look through list */
54         for (i=0;i<ARRAY_SIZE(wbcErr_ntstatus_map);i++) {
55                 if (wbcErr_ntstatus_map[i].wbc_err == wbc_err) {
56                         return wbcErr_ntstatus_map[i].nt_status;
57                 }
58         }
59
60         /* Default return */
61         return NT_STATUS_UNSUCCESSFUL;
62 }
63