Line data Source code
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.
10 : *
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.
15 : *
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.
20 : *
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/>.
23 : */
24 :
25 : #include "includes.h"
26 : #include "ntdomain.h"
27 : #include "librpc/gen_ndr/ndr_dssetup.h"
28 : #include "librpc/gen_ndr/ndr_dssetup_scompat.h"
29 : #include "secrets.h"
30 :
31 : #undef DBGC_CLASS
32 : #define DBGC_CLASS DBGC_RPC_SRV
33 :
34 : /********************************************************************
35 : Fill in a dssetup_DsRolePrimaryDomInfoBasic structure
36 : ********************************************************************/
37 :
38 17 : static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
39 : struct dssetup_DsRolePrimaryDomInfoBasic **info)
40 : {
41 17 : struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
42 17 : char *dnsdomain = NULL;
43 :
44 17 : DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
45 :
46 17 : basic = talloc_zero(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
47 17 : if (!basic) {
48 0 : DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
49 0 : return WERR_NOT_ENOUGH_MEMORY;
50 : }
51 :
52 17 : switch (lp_server_role()) {
53 0 : case ROLE_STANDALONE:
54 0 : basic->role = DS_ROLE_STANDALONE_SERVER;
55 0 : basic->domain = get_global_sam_name();
56 0 : break;
57 16 : case ROLE_DOMAIN_MEMBER:
58 16 : basic->role = DS_ROLE_MEMBER_SERVER;
59 16 : basic->domain = lp_workgroup();
60 16 : break;
61 0 : case ROLE_DOMAIN_BDC:
62 0 : basic->role = DS_ROLE_BACKUP_DC;
63 0 : basic->domain = get_global_sam_name();
64 0 : break;
65 1 : case ROLE_DOMAIN_PDC:
66 : case ROLE_IPA_DC:
67 1 : basic->role = DS_ROLE_PRIMARY_DC;
68 1 : basic->domain = get_global_sam_name();
69 1 : break;
70 : }
71 :
72 17 : if (secrets_fetch_domain_guid(lp_workgroup(), &basic->domain_guid)) {
73 13 : basic->flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
74 : }
75 :
76 : /* fill in some additional fields if we are a member of an AD domain */
77 :
78 17 : if (lp_security() == SEC_ADS) {
79 16 : dnsdomain = talloc_strdup(ctx, lp_realm());
80 16 : if (!dnsdomain) {
81 0 : return WERR_NOT_ENOUGH_MEMORY;
82 : }
83 16 : if (!strlower_m(dnsdomain)) {
84 0 : return WERR_INVALID_PARAMETER;
85 : }
86 16 : basic->dns_domain = dnsdomain;
87 :
88 : /* FIXME!! We really should fill in the correct forest
89 : name. Should get this information from winbindd. */
90 16 : basic->forest = dnsdomain;
91 : } else {
92 : /* security = domain should not fill in the dns or
93 : forest name */
94 1 : basic->dns_domain = NULL;
95 1 : basic->forest = NULL;
96 : }
97 :
98 17 : *info = basic;
99 :
100 17 : return WERR_OK;
101 : }
102 :
103 : /********************************************************************
104 : Implement the _dssetup_DsRoleGetPrimaryDomainInformation() call
105 : ********************************************************************/
106 :
107 17 : WERROR _dssetup_DsRoleGetPrimaryDomainInformation(struct pipes_struct *p,
108 : struct dssetup_DsRoleGetPrimaryDomainInformation *r)
109 : {
110 17 : WERROR werr = WERR_OK;
111 :
112 17 : switch (r->in.level) {
113 :
114 17 : case DS_ROLE_BASIC_INFORMATION: {
115 17 : struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
116 17 : werr = fill_dsrole_dominfo_basic(p->mem_ctx, &basic);
117 17 : if (W_ERROR_IS_OK(werr)) {
118 17 : r->out.info->basic = *basic;
119 : }
120 17 : break;
121 : }
122 0 : default:
123 0 : DEBUG(0,("_dssetup_DsRoleGetPrimaryDomainInformation: "
124 : "Unknown info level [%d]!\n", r->in.level));
125 0 : werr = WERR_INVALID_LEVEL;
126 : }
127 :
128 17 : return werr;
129 : }
130 :
131 : /****************************************************************
132 : ****************************************************************/
133 :
134 0 : WERROR _dssetup_DsRoleDnsNameToFlatName(struct pipes_struct *p,
135 : struct dssetup_DsRoleDnsNameToFlatName *r)
136 : {
137 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
138 0 : return WERR_NOT_SUPPORTED;
139 : }
140 :
141 : /****************************************************************
142 : ****************************************************************/
143 :
144 0 : WERROR _dssetup_DsRoleDcAsDc(struct pipes_struct *p,
145 : struct dssetup_DsRoleDcAsDc *r)
146 : {
147 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
148 0 : return WERR_NOT_SUPPORTED;
149 : }
150 :
151 : /****************************************************************
152 : ****************************************************************/
153 :
154 0 : WERROR _dssetup_DsRoleDcAsReplica(struct pipes_struct *p,
155 : struct dssetup_DsRoleDcAsReplica *r)
156 : {
157 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
158 0 : return WERR_NOT_SUPPORTED;
159 : }
160 :
161 : /****************************************************************
162 : ****************************************************************/
163 :
164 0 : WERROR _dssetup_DsRoleDemoteDc(struct pipes_struct *p,
165 : struct dssetup_DsRoleDemoteDc *r)
166 : {
167 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
168 0 : return WERR_NOT_SUPPORTED;
169 : }
170 :
171 : /****************************************************************
172 : ****************************************************************/
173 :
174 0 : WERROR _dssetup_DsRoleGetDcOperationProgress(struct pipes_struct *p,
175 : struct dssetup_DsRoleGetDcOperationProgress *r)
176 : {
177 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
178 0 : return WERR_NOT_SUPPORTED;
179 : }
180 :
181 : /****************************************************************
182 : ****************************************************************/
183 :
184 0 : WERROR _dssetup_DsRoleGetDcOperationResults(struct pipes_struct *p,
185 : struct dssetup_DsRoleGetDcOperationResults *r)
186 : {
187 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
188 0 : return WERR_NOT_SUPPORTED;
189 : }
190 :
191 : /****************************************************************
192 : ****************************************************************/
193 :
194 0 : WERROR _dssetup_DsRoleCancel(struct pipes_struct *p,
195 : struct dssetup_DsRoleCancel *r)
196 : {
197 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
198 0 : return WERR_NOT_SUPPORTED;
199 : }
200 :
201 : /****************************************************************
202 : ****************************************************************/
203 :
204 0 : WERROR _dssetup_DsRoleServerSaveStateForUpgrade(struct pipes_struct *p,
205 : struct dssetup_DsRoleServerSaveStateForUpgrade *r)
206 : {
207 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
208 0 : return WERR_NOT_SUPPORTED;
209 : }
210 :
211 : /****************************************************************
212 : ****************************************************************/
213 :
214 0 : WERROR _dssetup_DsRoleUpgradeDownlevelServer(struct pipes_struct *p,
215 : struct dssetup_DsRoleUpgradeDownlevelServer *r)
216 : {
217 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
218 0 : return WERR_NOT_SUPPORTED;
219 : }
220 :
221 : /****************************************************************
222 : ****************************************************************/
223 :
224 0 : WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(struct pipes_struct *p,
225 : struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
226 : {
227 0 : p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
228 0 : return WERR_NOT_SUPPORTED;
229 : }
230 :
231 : /* include the generated boilerplate */
232 : #include "librpc/gen_ndr/ndr_dssetup_scompat.c"
|