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)
38 switch (r->in.level) {
39 case DS_ROLE_BASIC_INFORMATION:
42 const char * const attrs[] = { "dnsDomain", "objectGUID", "name", NULL };
44 struct ldb_message **res;
45 union dssetup_DsRoleInfo *info;
46 enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
48 const char *domain = NULL;
49 const char *dns_domain = NULL;
50 const char *forest = NULL;
51 struct GUID domain_guid;
53 ZERO_STRUCT(domain_guid);
55 info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
56 W_ERROR_HAVE_NO_MEMORY(info);
58 /* TODO: we need to find out what we should return as standalone server */
60 switch (lp_server_role()) {
62 role = DS_ROLE_STANDALONE_SERVER;
64 case ROLE_DOMAIN_MEMBER:
65 role = DS_ROLE_MEMBER_SERVER;
68 role = DS_ROLE_BACKUP_DC;
71 role = DS_ROLE_PRIMARY_DC;
75 switch (lp_server_role()) {
77 domain = talloc_strdup(mem_ctx, lp_workgroup());
78 W_ERROR_HAVE_NO_MEMORY(domain);
80 case ROLE_DOMAIN_MEMBER:
81 domain = talloc_strdup(mem_ctx, lp_workgroup());
82 W_ERROR_HAVE_NO_MEMORY(domain);
83 /* TODO: what is with dns_domain and forest and guid? */
87 sam_ctx = samdb_connect(mem_ctx);
89 return WERR_SERVER_UNAVAILABLE;
92 ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
93 "(&(objectClass=domainDNS)(!(objectClass=builtinDomain)))");
95 return WERR_SERVER_UNAVAILABLE;
99 flags |= DS_ROLE_PRIMARY_DS_RUNNING;
100 flags |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
101 flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
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);
105 domain_guid = samdb_result_guid(res[0], "objectGUID");
109 info->basic.role = role;
110 info->basic.flags = flags;
111 info->basic.domain = domain;
112 info->basic.dns_domain = dns_domain;
113 info->basic.forest = forest;
114 info->basic.domain_guid = domain_guid;
119 case DS_ROLE_UPGRADE_STATUS:
121 union dssetup_DsRoleInfo *info;
123 info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
124 W_ERROR_HAVE_NO_MEMORY(info);
126 info->upgrade.upgrading = DS_ROLE_NOT_UPGRADING;
127 info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
132 case DS_ROLE_OP_STATUS:
134 union dssetup_DsRoleInfo *info;
136 info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
137 W_ERROR_HAVE_NO_MEMORY(info);
139 info->opstatus.status = DS_ROLE_OP_IDLE;
145 return WERR_INVALID_PARAM;
148 return WERR_INVALID_PARAM;
152 /*****************************************
153 NOTE! The remaining calls below were
154 removed in w2k3, so the DCESRV_FAULT()
155 replies are the correct implementation. Do
156 not try and fill these in with anything else
157 ******************************************/
160 dssetup_DsRoleDnsNameToFlatName
162 static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
163 struct dssetup_DsRoleDnsNameToFlatName *r)
165 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
172 static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
173 struct dssetup_DsRoleDcAsDc *r)
175 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
180 dssetup_DsRoleDcAsReplica
182 static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
183 struct dssetup_DsRoleDcAsReplica *r)
185 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
190 dssetup_DsRoleDemoteDc
192 static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
193 struct dssetup_DsRoleDemoteDc *r)
195 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
200 dssetup_DsRoleGetDcOperationProgress
202 static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
203 struct dssetup_DsRoleGetDcOperationProgress *r)
205 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
210 dssetup_DsRoleGetDcOperationResults
212 static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
213 struct dssetup_DsRoleGetDcOperationResults *r)
215 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
222 static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
223 struct dssetup_DsRoleCancel *r)
225 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
230 dssetup_DsRoleServerSaveStateForUpgrade
232 static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
233 struct dssetup_DsRoleServerSaveStateForUpgrade *r)
235 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
240 dssetup_DsRoleUpgradeDownlevelServer
242 static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
243 struct dssetup_DsRoleUpgradeDownlevelServer *r)
245 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
250 dssetup_DsRoleAbortDownlevelServerUpgrade
252 static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
253 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
255 DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
259 /* include the generated boilerplate */
260 #include "librpc/gen_ndr/ndr_dssetup_s.c"