s3-winbind: Add an update function for winbind cache.
[Samba.git] / source3 / lib / util_names.c
blobbd6e5c12026ab7dc167470bdc8821a5eb1e816c3
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
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 static char *smb_myname;
28 static char *smb_myworkgroup;
30 /***********************************************************************
31 Allocate and set myname. Ensure upper case.
32 ***********************************************************************/
34 bool set_global_myname(const char *myname)
36 SAFE_FREE(smb_myname);
37 smb_myname = SMB_STRDUP(myname);
38 if (!smb_myname)
39 return False;
40 strupper_m(smb_myname);
41 return True;
44 const char *global_myname(void)
46 return smb_myname;
49 /***********************************************************************
50 Allocate and set myworkgroup. Ensure upper case.
51 ***********************************************************************/
53 bool set_global_myworkgroup(const char *myworkgroup)
55 SAFE_FREE(smb_myworkgroup);
56 smb_myworkgroup = SMB_STRDUP(myworkgroup);
57 if (!smb_myworkgroup)
58 return False;
59 strupper_m(smb_myworkgroup);
60 return True;
63 const char *lp_workgroup(void)
65 return smb_myworkgroup;
68 /******************************************************************
69 get the default domain/netbios name to be used when dealing
70 with our passdb list of accounts
71 ******************************************************************/
73 const char *get_global_sam_name(void)
75 if (IS_DC) {
76 return lp_workgroup();
78 return global_myname();
81 void gfree_netbios_names(void)
83 SAFE_FREE( smb_myname );
84 SAFE_FREE( smb_myworkgroup );