s3:ntlm_auth: make logs more consistent with length check
[Samba.git] / source3 / rpc_server / dssetup / srv_dssetup_nt.c
blob932452bc13ba106b9af50d70a8be41e44f5b7006
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"
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"
31 #undef DBGC_CLASS
32 #define DBGC_CLASS DBGC_RPC_SRV
34 /********************************************************************
35 Fill in a dssetup_DsRolePrimaryDomInfoBasic structure
36 ********************************************************************/
38 static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx,
39 struct dssetup_DsRolePrimaryDomInfoBasic **info)
41 struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
42 char *dnsdomain = NULL;
44 DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));
46 basic = talloc_zero(ctx, struct dssetup_DsRolePrimaryDomInfoBasic);
47 if (!basic) {
48 DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n"));
49 return WERR_NOT_ENOUGH_MEMORY;
52 switch (lp_server_role()) {
53 case ROLE_STANDALONE:
54 basic->role = DS_ROLE_STANDALONE_SERVER;
55 basic->domain = get_global_sam_name();
56 break;
57 case ROLE_DOMAIN_MEMBER:
58 basic->role = DS_ROLE_MEMBER_SERVER;
59 basic->domain = lp_workgroup();
60 break;
61 case ROLE_DOMAIN_BDC:
62 basic->role = DS_ROLE_BACKUP_DC;
63 basic->domain = get_global_sam_name();
64 break;
65 case ROLE_DOMAIN_PDC:
66 case ROLE_IPA_DC:
67 basic->role = DS_ROLE_PRIMARY_DC;
68 basic->domain = get_global_sam_name();
69 break;
72 if (secrets_fetch_domain_guid(lp_workgroup(), &basic->domain_guid)) {
73 basic->flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
76 /* fill in some additional fields if we are a member of an AD domain */
78 if (lp_security() == SEC_ADS) {
79 dnsdomain = talloc_strdup(ctx, lp_realm());
80 if (!dnsdomain) {
81 return WERR_NOT_ENOUGH_MEMORY;
83 if (!strlower_m(dnsdomain)) {
84 return WERR_INVALID_PARAMETER;
86 basic->dns_domain = dnsdomain;
88 /* FIXME!! We really should fill in the correct forest
89 name. Should get this information from winbindd. */
90 basic->forest = dnsdomain;
91 } else {
92 /* security = domain should not fill in the dns or
93 forest name */
94 basic->dns_domain = NULL;
95 basic->forest = NULL;
98 *info = basic;
100 return WERR_OK;
103 /********************************************************************
104 Implement the _dssetup_DsRoleGetPrimaryDomainInformation() call
105 ********************************************************************/
107 WERROR _dssetup_DsRoleGetPrimaryDomainInformation(struct pipes_struct *p,
108 struct dssetup_DsRoleGetPrimaryDomainInformation *r)
110 WERROR werr = WERR_OK;
112 switch (r->in.level) {
114 case DS_ROLE_BASIC_INFORMATION: {
115 struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL;
116 werr = fill_dsrole_dominfo_basic(p->mem_ctx, &basic);
117 if (W_ERROR_IS_OK(werr)) {
118 r->out.info->basic = *basic;
120 break;
122 default:
123 DEBUG(0,("_dssetup_DsRoleGetPrimaryDomainInformation: "
124 "Unknown info level [%d]!\n", r->in.level));
125 werr = WERR_INVALID_LEVEL;
128 return werr;
131 /****************************************************************
132 ****************************************************************/
134 WERROR _dssetup_DsRoleDnsNameToFlatName(struct pipes_struct *p,
135 struct dssetup_DsRoleDnsNameToFlatName *r)
137 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
138 return WERR_NOT_SUPPORTED;
141 /****************************************************************
142 ****************************************************************/
144 WERROR _dssetup_DsRoleDcAsDc(struct pipes_struct *p,
145 struct dssetup_DsRoleDcAsDc *r)
147 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
148 return WERR_NOT_SUPPORTED;
151 /****************************************************************
152 ****************************************************************/
154 WERROR _dssetup_DsRoleDcAsReplica(struct pipes_struct *p,
155 struct dssetup_DsRoleDcAsReplica *r)
157 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
158 return WERR_NOT_SUPPORTED;
161 /****************************************************************
162 ****************************************************************/
164 WERROR _dssetup_DsRoleDemoteDc(struct pipes_struct *p,
165 struct dssetup_DsRoleDemoteDc *r)
167 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
168 return WERR_NOT_SUPPORTED;
171 /****************************************************************
172 ****************************************************************/
174 WERROR _dssetup_DsRoleGetDcOperationProgress(struct pipes_struct *p,
175 struct dssetup_DsRoleGetDcOperationProgress *r)
177 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
178 return WERR_NOT_SUPPORTED;
181 /****************************************************************
182 ****************************************************************/
184 WERROR _dssetup_DsRoleGetDcOperationResults(struct pipes_struct *p,
185 struct dssetup_DsRoleGetDcOperationResults *r)
187 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
188 return WERR_NOT_SUPPORTED;
191 /****************************************************************
192 ****************************************************************/
194 WERROR _dssetup_DsRoleCancel(struct pipes_struct *p,
195 struct dssetup_DsRoleCancel *r)
197 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
198 return WERR_NOT_SUPPORTED;
201 /****************************************************************
202 ****************************************************************/
204 WERROR _dssetup_DsRoleServerSaveStateForUpgrade(struct pipes_struct *p,
205 struct dssetup_DsRoleServerSaveStateForUpgrade *r)
207 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
208 return WERR_NOT_SUPPORTED;
211 /****************************************************************
212 ****************************************************************/
214 WERROR _dssetup_DsRoleUpgradeDownlevelServer(struct pipes_struct *p,
215 struct dssetup_DsRoleUpgradeDownlevelServer *r)
217 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
218 return WERR_NOT_SUPPORTED;
221 /****************************************************************
222 ****************************************************************/
224 WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(struct pipes_struct *p,
225 struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
227 p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
228 return WERR_NOT_SUPPORTED;
231 /* include the generated boilerplate */
232 #include "librpc/gen_ndr/ndr_dssetup_scompat.c"