2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1998
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
6 * Copyright (C) Paul Ashton 1997-1998,
7 * Copyright (C) Andrew Bartlett 2004.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* this module apparently provides an implementation of DCE/RPC over a
25 * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC
26 * documentation are available (in on-line form) from the X-Open group.
28 * this module should provide a level of abstraction between SMB
29 * and DCE/RPC, while minimising the amount of mallocs, unnecessary
30 * data copies, and network traffic.
32 * in this version, which takes a "let's learn what's going on and
33 * get something running" approach, there is additional network
34 * traffic generated, but the code should be easier to understand...
36 * ... if you read the docs. or stare at packets for weeks on end.
43 #define DBGC_CLASS DBGC_RPC_SRV
46 * A list of the rids of well known BUILTIN and Domain users
50 static const rid_name builtin_alias_rids
[] =
52 { BUILTIN_ALIAS_RID_ADMINS
, "Administrators" },
53 { BUILTIN_ALIAS_RID_USERS
, "Users" },
54 { BUILTIN_ALIAS_RID_GUESTS
, "Guests" },
55 { BUILTIN_ALIAS_RID_POWER_USERS
, "Power Users" },
57 { BUILTIN_ALIAS_RID_ACCOUNT_OPS
, "Account Operators" },
58 { BUILTIN_ALIAS_RID_SYSTEM_OPS
, "System Operators" },
59 { BUILTIN_ALIAS_RID_PRINT_OPS
, "Print Operators" },
60 { BUILTIN_ALIAS_RID_BACKUP_OPS
, "Backup Operators" },
61 { BUILTIN_ALIAS_RID_REPLICATOR
, "Replicator" },
65 /* array lookup of well-known Domain RID users. */
66 static const rid_name domain_user_rids
[] =
68 { DOMAIN_USER_RID_ADMIN
, "Administrator" },
69 { DOMAIN_USER_RID_GUEST
, "Guest" },
73 /* array lookup of well-known Domain RID groups. */
74 static const rid_name domain_group_rids
[] =
76 { DOMAIN_GROUP_RID_ADMINS
, "Domain Admins" },
77 { DOMAIN_GROUP_RID_USERS
, "Domain Users" },
78 { DOMAIN_GROUP_RID_GUESTS
, "Domain Guests" },
83 /*******************************************************************
84 gets a domain user's groups from their already-calculated NT_USER_TOKEN
85 ********************************************************************/
86 NTSTATUS
nt_token_to_group_list(TALLOC_CTX
*mem_ctx
, const DOM_SID
*domain_sid
,
87 const NT_USER_TOKEN
*nt_token
,
88 int *numgroups
, DOM_GID
**pgids
)
93 gids
= TALLOC_ARRAY(mem_ctx
, DOM_GID
, nt_token
->num_sids
);
96 return NT_STATUS_NO_MEMORY
;
101 for (i
=PRIMARY_GROUP_SID_INDEX
; i
< nt_token
->num_sids
; i
++) {
102 if (sid_compare_domain(domain_sid
, &nt_token
->user_sids
[i
])==0) {
103 sid_peek_rid(&nt_token
->user_sids
[i
], &(gids
[*numgroups
].g_rid
));
104 gids
[*numgroups
].attr
=7;