| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Translate BUILTIN names to SIDs and vice versa
|
|---|
| 4 | Copyright (C) Volker Lendecke 2005
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program; if not, write to the Free Software
|
|---|
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include "includes.h"
|
|---|
| 22 |
|
|---|
| 23 | struct rid_name_map {
|
|---|
| 24 | uint32 rid;
|
|---|
| 25 | const char *name;
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | static const struct rid_name_map builtin_aliases[] = {
|
|---|
| 29 | { BUILTIN_ALIAS_RID_ADMINS, "Administrators" },
|
|---|
| 30 | { BUILTIN_ALIAS_RID_USERS, "Users" },
|
|---|
| 31 | { BUILTIN_ALIAS_RID_GUESTS, "Guests" },
|
|---|
| 32 | { BUILTIN_ALIAS_RID_POWER_USERS, "Power Users" },
|
|---|
| 33 | { BUILTIN_ALIAS_RID_ACCOUNT_OPS, "Account Operators" },
|
|---|
| 34 | { BUILTIN_ALIAS_RID_SYSTEM_OPS, "Server Operators" },
|
|---|
| 35 | { BUILTIN_ALIAS_RID_PRINT_OPS, "Print Operators" },
|
|---|
| 36 | { BUILTIN_ALIAS_RID_BACKUP_OPS, "Backup Operators" },
|
|---|
| 37 | { BUILTIN_ALIAS_RID_REPLICATOR, "Replicator" },
|
|---|
| 38 | { BUILTIN_ALIAS_RID_RAS_SERVERS, "RAS Servers" },
|
|---|
| 39 | { BUILTIN_ALIAS_RID_PRE_2K_ACCESS, "Pre-Windows 2000 Compatible Access" },
|
|---|
| 40 | { 0, NULL}};
|
|---|
| 41 |
|
|---|
| 42 | /*******************************************************************
|
|---|
| 43 | Look up a rid in the BUILTIN domain
|
|---|
| 44 | ********************************************************************/
|
|---|
| 45 | BOOL lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name)
|
|---|
| 46 | {
|
|---|
| 47 | const struct rid_name_map *aliases = builtin_aliases;
|
|---|
| 48 |
|
|---|
| 49 | while (aliases->name != NULL) {
|
|---|
| 50 | if (rid == aliases->rid) {
|
|---|
| 51 | *name = talloc_strdup(mem_ctx, aliases->name);
|
|---|
| 52 | return True;
|
|---|
| 53 | }
|
|---|
| 54 | aliases++;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | return False;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | /*******************************************************************
|
|---|
| 61 | Look up a name in the BUILTIN domain
|
|---|
| 62 | ********************************************************************/
|
|---|
| 63 | BOOL lookup_builtin_name(const char *name, uint32 *rid)
|
|---|
| 64 | {
|
|---|
| 65 | const struct rid_name_map *aliases = builtin_aliases;
|
|---|
| 66 |
|
|---|
| 67 | while (aliases->name != NULL) {
|
|---|
| 68 | if (strequal(name, aliases->name)) {
|
|---|
| 69 | *rid = aliases->rid;
|
|---|
| 70 | return True;
|
|---|
| 71 | }
|
|---|
| 72 | aliases++;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | return False;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | /*****************************************************************
|
|---|
| 79 | Return the name of the BUILTIN domain
|
|---|
| 80 | *****************************************************************/
|
|---|
| 81 |
|
|---|
| 82 | const char *builtin_domain_name(void)
|
|---|
| 83 | {
|
|---|
| 84 | return "BUILTIN";
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /*****************************************************************
|
|---|
| 88 | Check if the SID is the builtin SID (S-1-5-32).
|
|---|
| 89 | *****************************************************************/
|
|---|
| 90 |
|
|---|
| 91 | BOOL sid_check_is_builtin(const DOM_SID *sid)
|
|---|
| 92 | {
|
|---|
| 93 | return sid_equal(sid, &global_sid_Builtin);
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | /*****************************************************************
|
|---|
| 97 | Check if the SID is one of the builtin SIDs (S-1-5-32-a).
|
|---|
| 98 | *****************************************************************/
|
|---|
| 99 |
|
|---|
| 100 | BOOL sid_check_is_in_builtin(const DOM_SID *sid)
|
|---|
| 101 | {
|
|---|
| 102 | DOM_SID dom_sid;
|
|---|
| 103 | uint32 rid;
|
|---|
| 104 |
|
|---|
| 105 | sid_copy(&dom_sid, sid);
|
|---|
| 106 | sid_split_rid(&dom_sid, &rid);
|
|---|
| 107 |
|
|---|
| 108 | return sid_check_is_builtin(&dom_sid);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|