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_samr.h"
26 #include "librpc/gen_ndr/ndr_dssetup.h"
27 #include "rpc_server/common/common.h"
31 dssetup_DsRoleGetPrimaryDomainInformation
33 static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call,
35 struct dssetup_DsRoleGetPrimaryDomainInformation *r)
37 union dssetup_DsRoleInfo *info;
39 info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
40 W_ERROR_HAVE_NO_MEMORY(info);
42 switch (r->in.level) {
43 case DS_ROLE_BASIC_INFORMATION:
46 const char * const attrs[] = { "dnsDomain", "nTMixedDomain", "objectGUID", "name", NULL };
48 struct ldb_message **res;
49 enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
51 const char *domain = NULL;
52 const char *dns_domain = NULL;
53 const char *forest = NULL;
54 struct GUID domain_guid;
56 ZERO_STRUCT(domain_guid);
58 switch (lp_server_role()) {
60 role = DS_ROLE_STANDALONE_SERVER;
62 case ROLE_DOMAIN_MEMBER:
63 role = DS_ROLE_MEMBER_SERVER;
66 role = DS_ROLE_BACKUP_DC;
69 role = DS_ROLE_PRIMARY_DC;
73 switch (lp_server_role()) {
75 domain = talloc_strdup(mem_ctx, lp_workgroup());
76 W_ERROR_HAVE_NO_MEMORY(domain);
78 case ROLE_DOMAIN_MEMBER:
79 domain = talloc_strdup(mem_ctx, lp_workgroup());
80 W_ERROR_HAVE_NO_MEMORY(domain);
81 /* TODO: what is with dns_domain and forest and guid? */
85 sam_ctx = samdb_connect(mem_ctx);
87 return WERR_SERVER_UNAVAILABLE;
90 ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
91 "(&(objectClass=domainDNS)(!(objectClass=builtinDomain)))");
93 return WERR_SERVER_UNAVAILABLE;
96 flags = DS_ROLE_PRIMARY_DS_RUNNING;
98 if (samdb_result_uint(res[0], "nTMixedDomain", 0) == 1) {
99 flags |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
102 domain = samdb_result_string(res[0], "name", NULL);
103 dns_domain = samdb_result_string(res[0], "dnsDomain", NULL);
104 forest = samdb_result_string(res[0], "dnsDomain", NULL);
106 flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
107 domain_guid = samdb_result_guid(res[0], "objectGUID");
111 info->basic.role = role;
112 info->basic.flags = flags;
113 info->basic.domain = domain;
114 info->basic.dns_domain = dns_domain;
115 info->basic.forest = forest;
116 info->basic.domain_guid = domain_guid;
121 case DS_ROLE_UPGRADE_STATUS:
123 info->upgrade.upgrading = DS_ROLE_NOT_UPGRADING;
124 info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
129 case DS_ROLE_OP_STATUS:
131 info->opstatus.status = DS_ROLE_OP_IDLE;
137 return WERR_INVALID_PARAM;
140 return WERR_INVALID_PARAM;
144 /*****************************************
145 NOTE! The remaining calls below were
146 removed in w2k3, so the DCESRV_FAULT()
147 replies are the correct implementation. Do
148 not try and fill these in with anything else
149 ******************************************/
152 dssetup_DsRoleDnsNameToFlatName
154 static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
155 struct dssetup_DsRoleDnsNameToFlatName *r)
157 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
164 static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
165 struct dssetup_DsRoleDcAsDc *r)
167 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
172 dssetup_DsRoleDcAsReplica
174 static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
175 struct dssetup_DsRoleDcAsReplica *r)
177 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
182 dssetup_DsRoleDemoteDc
184 static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
185 struct dssetup_DsRoleDemoteDc *r)
187 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
192 dssetup_DsRoleGetDcOperationProgress
194 static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
195 struct dssetup_DsRoleGetDcOperationProgress *r)
197 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
202 dssetup_DsRoleGetDcOperationResults
204 static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
205 struct dssetup_DsRoleGetDcOperationResults *r)
207 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
214 static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
215 struct dssetup_DsRoleCancel *r)
217 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
222 dssetup_DsRoleServerSaveStateForUpgrade
224 static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
225 struct dssetup_DsRoleServerSaveStateForUpgrade *r)
227 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
232 dssetup_DsRoleUpgradeDownlevelServer
234 static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
235 struct dssetup_DsRoleUpgradeDownlevelServer *r)
237 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
242 dssetup_DsRoleAbortDownlevelServerUpgrade
244 static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
245 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
247 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
251 /* include the generated boilerplate */
252 #include "librpc/gen_ndr/ndr_dssetup_s.c"