2 Unix SMB/CIFS implementation.
4 common server info functions
6 Copyright (C) Stefan (metze) Metzmacher 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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "librpc/gen_ndr/ndr_srvsvc.h"
24 #include "librpc/gen_ndr/svcctl.h"
25 #include "rpc_server/dcerpc_server.h"
26 #include "dsdb/samdb/samdb.h"
27 #include "auth/auth.h"
30 Here are common server info functions used by some dcerpc server interfaces
33 /* This hardcoded value should go into a ldb database! */
34 _PUBLIC_ enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
36 enum srvsvc_PlatformId id;
38 id = lp_parm_int(-1, "server_info", "platform_id", PLATFORM_ID_NT);
43 _PUBLIC_ const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, const char *server_unc)
45 const char *p = server_unc;
47 /* if there's no string return our NETBIOS name */
49 return talloc_strdup(mem_ctx, lp_netbios_name());
52 /* if there're '\\\\' in front remove them otherwise just pass the string */
53 if (p[0] == '\\' && p[1] == '\\') {
57 return talloc_strdup(mem_ctx, p);
60 const char *dcesrv_common_get_domain_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
62 return talloc_strdup(mem_ctx, lp_workgroup());
65 /* This hardcoded value should go into a ldb database! */
66 _PUBLIC_ uint32_t dcesrv_common_get_version_major(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
68 return lp_parm_int(-1, "server_info", "version_major", 5);
71 /* This hardcoded value should go into a ldb database! */
72 _PUBLIC_ uint32_t dcesrv_common_get_version_minor(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
74 return lp_parm_int(-1, "server_info", "version_minor", 2);
77 /* This hardcoded value should go into a ldb database! */
78 _PUBLIC_ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
80 return lp_parm_int(-1, "server_info", "version_build", 3790);
83 /* This hardcoded value should go into a ldb database! */
84 _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
86 int default_server_announce = 0;
87 default_server_announce |= SV_TYPE_WORKSTATION;
88 default_server_announce |= SV_TYPE_SERVER;
89 default_server_announce |= SV_TYPE_SERVER_UNIX;
91 switch (lp_announce_as()) {
92 case ANNOUNCE_AS_NT_SERVER:
93 default_server_announce |= SV_TYPE_SERVER_NT;
95 case ANNOUNCE_AS_NT_WORKSTATION:
96 default_server_announce |= SV_TYPE_NT;
98 case ANNOUNCE_AS_WIN95:
99 default_server_announce |= SV_TYPE_WIN95_PLUS;
101 case ANNOUNCE_AS_WFW:
102 default_server_announce |= SV_TYPE_WFW;
108 switch (lp_server_role()) {
109 case ROLE_DOMAIN_MEMBER:
110 default_server_announce |= SV_TYPE_DOMAIN_MEMBER;
112 case ROLE_DOMAIN_CONTROLLER:
114 struct ldb_context *samctx;
115 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
120 samctx = samdb_connect(tmp_ctx, anonymous_session(tmp_ctx));
121 if (samctx == NULL) {
122 DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
124 /* Determine if we are the pdc */
125 BOOL is_pdc = samdb_is_pdc(samctx);
127 default_server_announce |= SV_TYPE_DOMAIN_CTRL;
129 default_server_announce |= SV_TYPE_DOMAIN_BAKCTRL;
133 talloc_free(tmp_ctx);
136 case ROLE_STANDALONE:
140 if (lp_time_server())
141 default_server_announce |= SV_TYPE_TIME_SOURCE;
144 default_server_announce |= SV_TYPE_DFS_SERVER;
149 /* TODO: announce us as print server when we are a print server */
150 BOOL is_print_server = False;
151 if (is_print_server) {
152 default_server_announce |= SV_TYPE_PRINTQ_SERVER;
156 return default_server_announce;
159 /* This hardcoded value should go into a ldb database! */
160 _PUBLIC_ const char *dcesrv_common_get_lan_root(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
162 return talloc_strdup(mem_ctx, "");
165 /* This hardcoded value should go into a ldb database! */
166 _PUBLIC_ uint32_t dcesrv_common_get_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
171 /* This hardcoded value should go into a ldb database! */
172 _PUBLIC_ uint32_t dcesrv_common_get_disc(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
177 /* This hardcoded value should go into a ldb database! */
178 _PUBLIC_ uint32_t dcesrv_common_get_hidden(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
183 /* This hardcoded value should go into a ldb database! */
184 _PUBLIC_ uint32_t dcesrv_common_get_announce(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
189 /* This hardcoded value should go into a ldb database! */
190 _PUBLIC_ uint32_t dcesrv_common_get_anndelta(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
195 /* This hardcoded value should go into a ldb database! */
196 _PUBLIC_ uint32_t dcesrv_common_get_licenses(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
201 /* This hardcoded value should go into a ldb database! */
202 _PUBLIC_ const char *dcesrv_common_get_userpath(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
204 return talloc_strdup(mem_ctx, "c:\\");
207 #define INVALID_SHARE_NAME_CHARS " \"*+,./:;<=>?[\\]|"
209 _PUBLIC_ bool dcesrv_common_validate_share_name(TALLOC_CTX *mem_ctx, const char *share_name)
211 if (strpbrk(share_name, INVALID_SHARE_NAME_CHARS)) {