s3:rpcd_witness.idl: introduce definitions for rpcd_witness_registration.tdb records
[Samba.git] / source3 / lib / util_names.c
blobb62ddb302c6dff18ec524da4c9c090771b819544
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Jeremy Allison 2001-2007
6 Copyright (C) Simo Sorce 2001
7 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
8 Copyright (C) James Peach 2006
9 Copyright (C) Andrew Bartlett 2010-2011
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 /******************************************************************
28 get the default domain/netbios name to be used when dealing
29 with our passdb list of accounts
30 ******************************************************************/
32 const char *get_global_sam_name(void)
34 if (IS_DC) {
35 return lp_workgroup();
37 return lp_netbios_name();
41 /******************************************************************
42 Get the default domain/netbios name to be used when
43 testing authentication.
44 ******************************************************************/
46 const char *my_sam_name(void)
48 if (lp_server_role() == ROLE_STANDALONE) {
49 return lp_netbios_name();
52 return lp_workgroup();
55 bool is_allowed_domain(const char *domain_name)
57 const char **ignored_domains = NULL;
58 const char **dom = NULL;
60 ignored_domains = lp_parm_string_list(-1,
61 "winbind",
62 "ignore domains",
63 NULL);
65 for (dom = ignored_domains; dom != NULL && *dom != NULL; dom++) {
66 if (gen_fnmatch(*dom, domain_name) == 0) {
67 DBG_NOTICE("Ignoring domain '%s'\n", domain_name);
68 return false;
72 if (lp_allow_trusted_domains()) {
73 return true;
76 if (strequal(lp_workgroup(), domain_name)) {
77 return true;
80 if (is_myname(domain_name)) {
81 return true;
84 DBG_NOTICE("Not trusted domain '%s'\n", domain_name);
85 return false;