source: vendor/3.6.0/source3/libads/ads_status.h

Last change on this file was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

File size: 2.6 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 ads (active directory) utility library
4 Copyright (C) Andrew Tridgell 2001
5 Copyright (C) Remus Koos 2001
6 Copyright (C) Andrew Bartlett 2001
7
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef _LIBADS_ADS_STATUS_H_
24#define _LIBADS_ADS_STATUS_H_
25
26/* there are 5 possible types of errors the ads subsystem can produce */
27enum ads_error_type {ENUM_ADS_ERROR_KRB5, ENUM_ADS_ERROR_GSS,
28 ENUM_ADS_ERROR_LDAP, ENUM_ADS_ERROR_SYSTEM, ENUM_ADS_ERROR_NT};
29
30typedef struct {
31 enum ads_error_type error_type;
32 union err_state{
33 int rc;
34 NTSTATUS nt_status;
35 } err;
36 /* For error_type = ENUM_ADS_ERROR_GSS minor_status describe GSS API error */
37 /* Where rc represents major_status of GSS API error */
38 int minor_status;
39} ADS_STATUS;
40
41/* macros to simplify error returning */
42#define ADS_ERROR(rc) ADS_ERROR_LDAP(rc)
43#define ADS_ERROR_LDAP(rc) ads_build_error(ENUM_ADS_ERROR_LDAP, rc, 0)
44#define ADS_ERROR_SYSTEM(rc) ads_build_error(ENUM_ADS_ERROR_SYSTEM, rc?rc:EINVAL, 0)
45#define ADS_ERROR_KRB5(rc) ads_build_error(ENUM_ADS_ERROR_KRB5, rc, 0)
46#define ADS_ERROR_GSS(rc, minor) ads_build_error(ENUM_ADS_ERROR_GSS, rc, minor)
47#define ADS_ERROR_NT(rc) ads_build_nt_error(ENUM_ADS_ERROR_NT,rc)
48
49#define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
50#define ADS_SUCCESS ADS_ERROR(0)
51
52#define ADS_ERROR_HAVE_NO_MEMORY(x) do { \
53 if (!(x)) {\
54 return ADS_ERROR(LDAP_NO_MEMORY);\
55 }\
56} while (0)
57
58/* The following definitions come from libads/ads_status.c */
59
60ADS_STATUS ads_build_error(enum ads_error_type etype,
61 int rc, int minor_status);
62ADS_STATUS ads_build_nt_error(enum ads_error_type etype,
63 NTSTATUS nt_status);
64NTSTATUS ads_ntstatus(ADS_STATUS status);
65const char *ads_errstr(ADS_STATUS status);
66NTSTATUS gss_err_to_ntstatus(uint32 maj, uint32 min);
67
68#endif /* _LIBADS_ADS_STATUS_H_ */
Note: See TracBrowser for help on using the repository browser.