summaryrefslogtreecommitdiff
path: root/source4/libgpo/ads_convenience.h
blob: 13bd54b5882dfae1823ae1b02d2a420dfb962a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
   Samba CIFS implementation
   ADS convenience functions for GPO

   Copyright (C) 2008 Jelmer Vernooij, jelmer@samba.org
   Copyright (C) 2008 Wilco Baan Hofman, wilco@baanhofman.nl

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ADS_CONVENIENCE_H__
#define __ADS_CONVENIENCE_H__

#define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
#define ADS_ERROR(rc) ads_build_ldap_error(rc)
#define ADS_ERROR_NT(rc) ads_build_nt_error(rc)
#define ADS_ERROR_HAVE_NO_MEMORY(x) do { \
        if (!(x)) {\
                return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);\
        }\
} while (0)

#define LDAP_SCOPE_BASE		LDB_SCOPE_BASE
#define LDAP_SCOPE_SUBTREE	LDB_SCOPE_SUBTREE
#define LDAP_SCOPE_ONELEVEL	LDB_SCOPE_ONELEVEL




typedef struct {
	struct libnet_context *netctx;
	struct ldb_context *ldbctx;
} ADS_STRUCT;

typedef struct ldb_result LDAPMessage;
typedef struct void ** ADS_MODLIST;

/* there are 3 possible types of errors the ads subsystem can produce */
enum ads_error_type { ENUM_ADS_ERROR_LDAP, ENUM_ADS_ERROR_SYSTEM, ENUM_ADS_ERROR_NT};

typedef struct {
	enum ads_error_type error_type;
	union err_state{
		int rc;
		NTSTATUS nt_status;
	} err;
	int minor_status;
} ADS_STATUS;

#endif