2 Unix SMB/CIFS implementation.
4 endpoint server for the dssetup pipe
6 Copyright (C) Andrew Tridgell 2004
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 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "rpc_server/dcerpc_server.h"
25 #include "librpc/gen_ndr/ndr_dssetup.h"
26 #include "rpc_server/common/common.h"
30 dssetup_DsRoleGetPrimaryDomainInformation
32 static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call,
34 struct dssetup_DsRoleGetPrimaryDomainInformation *r)
36 union dssetup_DsRoleInfo *info;
38 info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
39 W_ERROR_HAVE_NO_MEMORY(info);
41 switch (r->in.level) {
42 case DS_ROLE_BASIC_INFORMATION:
45 const char * const attrs[] = { "dnsDomain", "nTMixedDomain", "objectGUID", "name", NULL };
47 struct ldb_message **res;
48 enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
50 const char *domain = NULL;
51 const char *dns_domain = NULL;
52 const char *forest = NULL;
53 struct GUID domain_guid;
55 ZERO_STRUCT(domain_guid);
57 switch (lp_server_role()) {
59 role = DS_ROLE_STANDALONE_SERVER;
61 case ROLE_DOMAIN_MEMBER:
62 role = DS_ROLE_MEMBER_SERVER;
65 role = DS_ROLE_BACKUP_DC;
68 role = DS_ROLE_PRIMARY_DC;
72 switch (lp_server_role()) {
74 domain = talloc_strdup(mem_ctx, lp_workgroup());
75 W_ERROR_HAVE_NO_MEMORY(domain);
77 case ROLE_DOMAIN_MEMBER:
78 domain = talloc_strdup(mem_ctx, lp_workgroup());
79 W_ERROR_HAVE_NO_MEMORY(domain);
80 /* TODO: what is with dns_domain and forest and guid? */
84 sam_ctx = samdb_connect(mem_ctx);
86 return WERR_SERVER_UNAVAILABLE;
89 ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
90 "(&(objectClass=domainDNS)(!(objectClass=builtinDomain)))");
92 return WERR_SERVER_UNAVAILABLE;
95 flags = DS_ROLE_PRIMARY_DS_RUNNING;
97 if (samdb_result_uint(res[0], "nTMixedDomain", 0) == 1) {
98 flags |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
101 domain = samdb_result_string(res[0], "name", NULL);
102 dns_domain = samdb_result_string(res[0], "dnsDomain", NULL);
103 forest = samdb_result_string(res[0], "dnsDomain", NULL);
105 flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
106 domain_guid = samdb_result_guid(res[0], "objectGUID");
110 info->basic.role = role;
111 info->basic.flags = flags;
112 info->basic.domain = domain;
113 info->basic.dns_domain = dns_domain;
114 info->basic.forest = forest;
115 info->basic.domain_guid = domain_guid;
120 case DS_ROLE_UPGRADE_STATUS:
122 info->upgrade.upgrading = DS_ROLE_NOT_UPGRADING;
123 info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
128 case DS_ROLE_OP_STATUS:
130 info->opstatus.status = DS_ROLE_OP_IDLE;
136 return WERR_INVALID_PARAM;
139 return WERR_INVALID_PARAM;
143 /*****************************************
144 NOTE! The remaining calls below were
145 removed in w2k3, so the DCESRV_FAULT()
146 replies are the correct implementation. Do
147 not try and fill these in with anything else
148 ******************************************/
151 dssetup_DsRoleDnsNameToFlatName
153 static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
154 struct dssetup_DsRoleDnsNameToFlatName *r)
156 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
163 static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
164 struct dssetup_DsRoleDcAsDc *r)
166 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
171 dssetup_DsRoleDcAsReplica
173 static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
174 struct dssetup_DsRoleDcAsReplica *r)
176 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
181 dssetup_DsRoleDemoteDc
183 static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
184 struct dssetup_DsRoleDemoteDc *r)
186 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
191 dssetup_DsRoleGetDcOperationProgress
193 static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
194 struct dssetup_DsRoleGetDcOperationProgress *r)
196 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
201 dssetup_DsRoleGetDcOperationResults
203 static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
204 struct dssetup_DsRoleGetDcOperationResults *r)
206 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
213 static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
214 struct dssetup_DsRoleCancel *r)
216 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
221 dssetup_DsRoleServerSaveStateForUpgrade
223 static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
224 struct dssetup_DsRoleServerSaveStateForUpgrade *r)
226 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
231 dssetup_DsRoleUpgradeDownlevelServer
233 static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
234 struct dssetup_DsRoleUpgradeDownlevelServer *r)
236 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
241 dssetup_DsRoleAbortDownlevelServerUpgrade
243 static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
244 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
246 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
250 /* include the generated boilerplate */
251 #include "librpc/gen_ndr/ndr_dssetup_s.c"