tiny simplification
[Samba/gebeck_regimport.git] / source3 / rpc_server / srv_dssetup_nt.c
blobea535a337599cabecf734957d27c85e8c6dd3554
1 /*
2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997.
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997.
6 * Copyright (C) Paul Ashton 1997.
7 * Copyright (C) Jeremy Allison 2001.
8 * Copyright (C) Gerald Carter 2002.
9 * Copyright (C) Guenther Deschner 2008.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #include "includes.h"
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_RPC_SRV
30 /********************************************************************
31 Fill in a dssetup_DsRolePrimaryDomInfoBasic structure
32 ********************************************************************/
34 static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
35 struct dssetup_DsRolePrimaryDomInfoBasic **info)
37 struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
38 fstring dnsdomain;
40 DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
42 basic = TALLOC_ZERO_P(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
43 if (!basic) {
44 DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
45 return WERR_NOMEM;
48 switch (lp_server_role()) {
49 case ROLE_STANDALONE:
50 basic->role = DS_ROLE_STANDALONE_SERVER;
51 basic->domain = get_global_sam_name();
52 break;
53 case ROLE_DOMAIN_MEMBER:
54 basic->role = DS_ROLE_MEMBER_SERVER;
55 basic->domain = lp_workgroup();
56 break;
57 case ROLE_DOMAIN_BDC:
58 basic->role = DS_ROLE_BACKUP_DC;
59 basic->domain = get_global_sam_name();
60 break;
61 case ROLE_DOMAIN_PDC:
62 basic->role = DS_ROLE_PRIMARY_DC;
63 basic->domain = get_global_sam_name();
64 break;
67 if (secrets_fetch_domain_guid(lp_workgroup(), &basic->domain_guid)) {
68 basic->flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
71 /* fill in some additional fields if we are a member of an AD domain */
73 if (lp_security() == SEC_ADS) {
74 fstrcpy(dnsdomain, lp_realm());
75 strlower_m(dnsdomain);
76 basic->dns_domain = dnsdomain;
78 /* FIXME!! We really should fill in the correct forest
79 name. Should get this information from winbindd. */
80 basic->forest = dnsdomain;
81 } else {
82 /* security = domain should not fill in the dns or
83 forest name */
84 basic->dns_domain = NULL;
85 basic->forest = NULL;
88 *info = basic;
90 return WERR_OK;
93 /********************************************************************
94 Implement the _dssetup_DsRoleGetPrimaryDomainInformation() call
95 ********************************************************************/
97 WERROR _dssetup_DsRoleGetPrimaryDomainInformation(pipes_struct *p,
98 struct dssetup_DsRoleGetPrimaryDomainInformation *r)
100 WERROR werr = WERR_OK;
102 switch (r->in.level) {
104 case DS_ROLE_BASIC_INFORMATION: {
105 struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
106 werr = fill_dsrole_dominfo_basic(p->mem_ctx, &basic);
107 if (W_ERROR_IS_OK(werr)) {
108 r->out.info->basic = *basic;
110 break;
112 default:
113 DEBUG(0,("_dssetup_DsRoleGetPrimaryDomainInformation: "
114 "Unknown info level [%d]!\n", r->in.level));
115 werr = WERR_UNKNOWN_LEVEL;
118 return werr;
121 /****************************************************************
122 ****************************************************************/
124 WERROR _dssetup_DsRoleDnsNameToFlatName(pipes_struct *p,
125 struct dssetup_DsRoleDnsNameToFlatName *r)
127 p->rng_fault_state = true;
128 return WERR_NOT_SUPPORTED;
131 /****************************************************************
132 ****************************************************************/
134 WERROR _dssetup_DsRoleDcAsDc(pipes_struct *p,
135 struct dssetup_DsRoleDcAsDc *r)
137 p->rng_fault_state = true;
138 return WERR_NOT_SUPPORTED;
141 /****************************************************************
142 ****************************************************************/
144 WERROR _dssetup_DsRoleDcAsReplica(pipes_struct *p,
145 struct dssetup_DsRoleDcAsReplica *r)
147 p->rng_fault_state = true;
148 return WERR_NOT_SUPPORTED;
151 /****************************************************************
152 ****************************************************************/
154 WERROR _dssetup_DsRoleDemoteDc(pipes_struct *p,
155 struct dssetup_DsRoleDemoteDc *r)
157 p->rng_fault_state = true;
158 return WERR_NOT_SUPPORTED;
161 /****************************************************************
162 ****************************************************************/
164 WERROR _dssetup_DsRoleGetDcOperationProgress(pipes_struct *p,
165 struct dssetup_DsRoleGetDcOperationProgress *r)
167 p->rng_fault_state = true;
168 return WERR_NOT_SUPPORTED;
171 /****************************************************************
172 ****************************************************************/
174 WERROR _dssetup_DsRoleGetDcOperationResults(pipes_struct *p,
175 struct dssetup_DsRoleGetDcOperationResults *r)
177 p->rng_fault_state = true;
178 return WERR_NOT_SUPPORTED;
181 /****************************************************************
182 ****************************************************************/
184 WERROR _dssetup_DsRoleCancel(pipes_struct *p,
185 struct dssetup_DsRoleCancel *r)
187 p->rng_fault_state = true;
188 return WERR_NOT_SUPPORTED;
191 /****************************************************************
192 ****************************************************************/
194 WERROR _dssetup_DsRoleServerSaveStateForUpgrade(pipes_struct *p,
195 struct dssetup_DsRoleServerSaveStateForUpgrade *r)
197 p->rng_fault_state = true;
198 return WERR_NOT_SUPPORTED;
201 /****************************************************************
202 ****************************************************************/
204 WERROR _dssetup_DsRoleUpgradeDownlevelServer(pipes_struct *p,
205 struct dssetup_DsRoleUpgradeDownlevelServer *r)
207 p->rng_fault_state = true;
208 return WERR_NOT_SUPPORTED;
211 /****************************************************************
212 ****************************************************************/
214 WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(pipes_struct *p,
215 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
217 p->rng_fault_state = true;
218 return WERR_NOT_SUPPORTED;