source: trunk/server/source3/param/loadparm_server_role.c

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 3.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
5
6 Largely re-written by Andrew Tridgell, September 1994
7
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
12 Copyright (C) Michael Adam 2008
13 Copyright (C) Andrew Bartlett 2010
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 3 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
27*/
28#include "includes.h"
29
30/*******************************************************************
31 Set the server type we will announce as via nmbd.
32********************************************************************/
33static int server_role;
34
35static const struct srv_role_tab {
36 uint32 role;
37 const char *role_str;
38} srv_role_tab [] = {
39 { ROLE_STANDALONE, "ROLE_STANDALONE" },
40 { ROLE_DOMAIN_MEMBER, "ROLE_DOMAIN_MEMBER" },
41 { ROLE_DOMAIN_BDC, "ROLE_DOMAIN_BDC" },
42 { ROLE_DOMAIN_PDC, "ROLE_DOMAIN_PDC" },
43 { 0, NULL }
44};
45
46const char* server_role_str(uint32 role)
47{
48 int i = 0;
49 for (i=0; srv_role_tab[i].role_str; i++) {
50 if (role == srv_role_tab[i].role) {
51 return srv_role_tab[i].role_str;
52 }
53 }
54 return NULL;
55}
56
57void set_server_role(void)
58{
59 server_role = ROLE_STANDALONE;
60
61 switch (lp_security()) {
62 case SEC_SHARE:
63 if (lp_domain_logons())
64 DEBUG(0, ("Server's Role (logon server) conflicts with share-level security\n"));
65 break;
66 case SEC_SERVER:
67 if (lp_domain_logons())
68 DEBUG(0, ("Server's Role (logon server) conflicts with server-level security\n"));
69 /* this used to be considered ROLE_DOMAIN_MEMBER but that's just wrong */
70 server_role = ROLE_STANDALONE;
71 break;
72 case SEC_DOMAIN:
73 if (lp_domain_logons()) {
74 DEBUG(1, ("Server's Role (logon server) NOT ADVISED with domain-level security\n"));
75 server_role = ROLE_DOMAIN_BDC;
76 break;
77 }
78 server_role = ROLE_DOMAIN_MEMBER;
79 break;
80 case SEC_ADS:
81 if (lp_domain_logons()) {
82 server_role = ROLE_DOMAIN_PDC;
83 break;
84 }
85 server_role = ROLE_DOMAIN_MEMBER;
86 break;
87 case SEC_USER:
88 if (lp_domain_logons()) {
89
90 if (lp_domain_master_true_or_auto()) /* auto or yes */
91 server_role = ROLE_DOMAIN_PDC;
92 else
93 server_role = ROLE_DOMAIN_BDC;
94 }
95 break;
96 default:
97 DEBUG(0, ("Server's Role undefined due to unknown security mode\n"));
98 break;
99 }
100
101 DEBUG(10, ("set_server_role: role = %s\n", server_role_str(server_role)));
102}
103
104/***********************************************************
105 returns role of Samba server
106************************************************************/
107
108int lp_server_role(void)
109{
110 return server_role;
111}
Note: See TracBrowser for help on using the repository browser.