summaryrefslogtreecommitdiff
path: root/source4/utils/net/drs/net_drs.h
blob: dc5bb8c9d012732f076b960ebe92b1a3b5f17e85 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
   Unix SMB/CIFS implementation.

   Implements functions offered by repadmin.exe tool under Windows

   Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2010

   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 NET_DRS_H_
#define NET_DRS_H_

#include "librpc/gen_ndr/ndr_drsuapi_c.h"


/**
 * Check for critical error
 */
#define NET_DRS_CHECK_GOTO(_condition,_label,_msg) \
	do { \
	if (!(_condition)) { \
		d_printf(__location__": "#_condition" - %s\n", _msg); \
		goto _label; \
	} \
	} while (0)

/**
 * check allocated memory macro
 */
#define NET_DRS_NOMEM_GOTO(_ptr,_label) \
	NET_DRS_CHECK_GOTO(_ptr, _label, "Not enough memory!")


/**
 * DRSUAPI binding context
 */
struct net_drs_connection {
	/* DRSUAPI connection context */
	struct dcerpc_binding 	*binding;
	struct dcerpc_pipe 	*drs_pipe;
	struct policy_handle 	bind_handle;

	/* length of bind info structure returned by remote DC
	 * 'net drs bind' command make use of this value */
	uint32_t bind_info_len;

	/* remote DC DRSUAPI capabilities */
	struct drsuapi_DsBindInfo48 info48;
};


/**
 * net drs commands context
 */
struct net_drs_context {
	struct net_context 	*net_ctx;

	/* remote DC name supplied from command line */
	const char 		*dc_name;

	/* DRSUAPI connection to target DC */
	struct net_drs_connection *drs_conn;

	/* LDAP connection to DC */
	struct net_drs_ldap {
		struct ldb_context 	 *ldb;
		const struct ldb_message *rootdse;
	} ldap;
};


#include "utils/net/drs/net_drs_proto.h"

#endif /* NET_DRS_H_ */