summaryrefslogtreecommitdiffstats
path: root/source3/rpc_server/srv_dssetup_nt.c
blob: 2b18e6b2aeb914143cec45251f708a8a349dbcf2 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
 *  Unix SMB/CIFS implementation.
 *  RPC Pipe client / server routines
 *  Copyright (C) Andrew Tridgell               1992-1997.
 *  Copyright (C) Luke Kenneth Casson Leighton  1996-1997.
 *  Copyright (C) Paul Ashton                        1997.
 *  Copyright (C) Jeremy Allison                     2001.
 *  Copyright (C) Gerald Carter                      2002.
 *  Copyright (C) Guenther Deschner                  2008.
 *
 *  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/>.
 */

#include "includes.h"

#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV

/********************************************************************
 Fill in a dssetup_DsRolePrimaryDomInfoBasic structure
 ********************************************************************/

static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
					struct dssetup_DsRolePrimaryDomInfoBasic **info)
{
	struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
	char *dnsdomain = NULL;

	DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));

	basic = TALLOC_ZERO_P(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
	if (!basic) {
		DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
		return WERR_NOMEM;
	}

	switch (lp_server_role()) {
		case ROLE_STANDALONE:
			basic->role = DS_ROLE_STANDALONE_SERVER;
			basic->domain = get_global_sam_name();
			break;
		case ROLE_DOMAIN_MEMBER:
			basic->role = DS_ROLE_MEMBER_SERVER;
			basic->domain = lp_workgroup();
			break;
		case ROLE_DOMAIN_BDC:
			basic->role = DS_ROLE_BACKUP_DC;
			basic->domain = get_global_sam_name();
			break;
		case ROLE_DOMAIN_PDC:
			basic->role = DS_ROLE_PRIMARY_DC;
			basic->domain = get_global_sam_name();
			break;
	}

	if (secrets_fetch_domain_guid(lp_workgroup(), &basic->domain_guid)) {
		basic->flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
	}

	/* fill in some additional fields if we are a member of an AD domain */

	if (lp_security() == SEC_ADS) {
		dnsdomain = talloc_strdup(ctx, lp_realm());
		if (!dnsdomain) {
			return WERR_NOMEM;
		}
		strlower_m(dnsdomain);
		basic->dns_domain = dnsdomain;

		/* FIXME!! We really should fill in the correct forest
		   name.  Should get this information from winbindd.  */
		basic->forest = dnsdomain;
	} else {
		/* security = domain should not fill in the dns or
		   forest name */
		basic->dns_domain = NULL;
		basic->forest = NULL;
	}

	*info = basic;

	return WERR_OK;
}

/********************************************************************
 Implement the _dssetup_DsRoleGetPrimaryDomainInformation() call
 ********************************************************************/

WERROR _dssetup_DsRoleGetPrimaryDomainInformation(pipes_struct *p,
						  struct dssetup_DsRoleGetPrimaryDomainInformation *r)
{
	WERROR werr = WERR_OK;

	switch (r->in.level) {

		case DS_ROLE_BASIC_INFORMATION: {
			struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
			werr = fill_dsrole_dominfo_basic(p->mem_ctx, &basic);
			if (W_ERROR_IS_OK(werr)) {
				r->out.info->basic = *basic;
			}
			break;
		}
		default:
			DEBUG(0,("_dssetup_DsRoleGetPrimaryDomainInformation: "
				"Unknown info level [%d]!\n", r->in.level));
			werr = WERR_UNKNOWN_LEVEL;
	}

	return werr;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleDnsNameToFlatName(pipes_struct *p,
					struct dssetup_DsRoleDnsNameToFlatName *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleDcAsDc(pipes_struct *p,
			     struct dssetup_DsRoleDcAsDc *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleDcAsReplica(pipes_struct *p,
				  struct dssetup_DsRoleDcAsReplica *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleDemoteDc(pipes_struct *p,
			       struct dssetup_DsRoleDemoteDc *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleGetDcOperationProgress(pipes_struct *p,
					     struct dssetup_DsRoleGetDcOperationProgress *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleGetDcOperationResults(pipes_struct *p,
					    struct dssetup_DsRoleGetDcOperationResults *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleCancel(pipes_struct *p,
			     struct dssetup_DsRoleCancel *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleServerSaveStateForUpgrade(pipes_struct *p,
						struct dssetup_DsRoleServerSaveStateForUpgrade *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleUpgradeDownlevelServer(pipes_struct *p,
					     struct dssetup_DsRoleUpgradeDownlevelServer *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}

/****************************************************************
****************************************************************/

WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(pipes_struct *p,
						  struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
{
	p->rng_fault_state = true;
	return WERR_NOT_SUPPORTED;
}