2005-01-13 21:20:37 +03:00
/*
2002-01-30 09:08:46 +03:00
* Unix SMB / CIFS implementation .
2001-02-26 22:31:07 +03:00
* RPC Pipe client / server routines
* Copyright ( C ) Andrew Tridgell 1992 - 1997 ,
* Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 1997 ,
2002-07-15 14:35:28 +04:00
* Copyright ( C ) Paul Ashton 1997 ,
2006-02-16 04:06:21 +03:00
* Copyright ( C ) Jeremy Allison 2001 , 2006.
2002-08-17 19:34:15 +04:00
* Copyright ( C ) Rafal Szczesniak 2002 ,
2004-04-13 18:39:48 +04:00
* Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2002 ,
2005-01-13 21:20:37 +03:00
* Copyright ( C ) Simo Sorce 2003.
2005-03-10 21:50:47 +03:00
* Copyright ( C ) Gerald ( Jerry ) Carter 2005.
2006-02-04 01:19:41 +03:00
* Copyright ( C ) Volker Lendecke 2005.
2008-02-27 21:38:48 +03:00
* Copyright ( C ) Guenther Deschner 2008.
2001-02-26 22:31:07 +03:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2001-02-26 22:31:07 +03:00
* ( at your option ) any later version .
2008-02-14 15:12:28 +03:00
*
2001-02-26 22:31:07 +03:00
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2008-02-14 15:12:28 +03:00
*
2001-02-26 22:31:07 +03:00
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2001-02-26 22:31:07 +03:00
*/
/* This is the implementation of the lsa server code. */
# include "includes.h"
2009-11-26 20:21:28 +03:00
# include "../librpc/gen_ndr/srv_lsa.h"
2001-02-26 22:31:07 +03:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_RPC_SRV
2008-10-24 04:01:16 +04:00
# define MAX_LOOKUP_SIDS 0x5000 /* 20480 */
2001-07-09 22:32:54 +04:00
extern PRIVS privs [ ] ;
2009-05-20 22:52:11 +04:00
enum lsa_handle_type { LSA_HANDLE_POLICY_TYPE = 1 , LSA_HANDLE_ACCOUNT_TYPE } ;
2001-07-09 22:32:54 +04:00
struct lsa_info {
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2009-10-30 01:50:20 +03:00
const char * name ;
2002-11-13 02:20:50 +03:00
uint32 access ;
2009-05-20 22:52:11 +04:00
enum lsa_handle_type type ;
2009-10-30 01:50:20 +03:00
struct security_descriptor * sd ;
2009-05-20 22:52:11 +04:00
} ;
const struct generic_mapping lsa_account_mapping = {
LSA_ACCOUNT_READ ,
LSA_ACCOUNT_WRITE ,
LSA_ACCOUNT_EXECUTE ,
LSA_ACCOUNT_ALL_ACCESS
2001-07-09 22:32:54 +04:00
} ;
2009-05-20 22:52:11 +04:00
const struct generic_mapping lsa_policy_mapping = {
2008-02-27 17:49:31 +03:00
LSA_POLICY_READ ,
LSA_POLICY_WRITE ,
LSA_POLICY_EXECUTE ,
LSA_POLICY_ALL_ACCESS
2001-12-18 02:03:23 +03:00
} ;
2009-10-27 15:50:43 +03:00
const struct generic_mapping lsa_secret_mapping = {
LSA_SECRET_READ ,
LSA_SECRET_WRITE ,
LSA_SECRET_EXECUTE ,
LSA_SECRET_ALL_ACCESS
} ;
2009-10-27 17:29:02 +03:00
const struct generic_mapping lsa_trusted_domain_mapping = {
LSA_TRUSTED_DOMAIN_READ ,
LSA_TRUSTED_DOMAIN_WRITE ,
LSA_TRUSTED_DOMAIN_EXECUTE ,
LSA_TRUSTED_DOMAIN_ALL_ACCESS
} ;
2008-02-18 16:40:34 +03:00
/***************************************************************************
init_lsa_ref_domain_list - adds a domain if it ' s not already in , returns the index .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int init_lsa_ref_domain_list ( TALLOC_CTX * mem_ctx ,
struct lsa_RefDomainList * ref ,
const char * dom_name ,
2010-05-21 05:25:01 +04:00
struct dom_sid * dom_sid )
2008-02-18 16:40:34 +03:00
{
int num = 0 ;
if ( dom_name ! = NULL ) {
for ( num = 0 ; num < ref - > count ; num + + ) {
if ( sid_equal ( dom_sid , ref - > domains [ num ] . sid ) ) {
return num ;
}
}
} else {
num = ref - > count ;
}
2008-10-24 04:01:16 +04:00
if ( num > = LSA_REF_DOMAIN_LIST_MULTIPLIER ) {
2008-02-18 16:40:34 +03:00
/* index not found, already at maximum domain limit */
return - 1 ;
}
ref - > count = num + 1 ;
2008-10-24 04:01:16 +04:00
ref - > max_size = LSA_REF_DOMAIN_LIST_MULTIPLIER ;
2008-02-18 16:40:34 +03:00
ref - > domains = TALLOC_REALLOC_ARRAY ( mem_ctx , ref - > domains ,
struct lsa_DomainInfo , ref - > count ) ;
if ( ! ref - > domains ) {
return - 1 ;
}
2008-03-04 13:06:02 +03:00
ZERO_STRUCT ( ref - > domains [ num ] ) ;
2008-02-18 16:40:34 +03:00
init_lsa_StringLarge ( & ref - > domains [ num ] . name , dom_name ) ;
ref - > domains [ num ] . sid = sid_dup_talloc ( mem_ctx , dom_sid ) ;
if ( ! ref - > domains [ num ] . sid ) {
return - 1 ;
}
return num ;
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
initialize a lsa_DomainInfo structure .
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
static void init_dom_query_3 ( struct lsa_DomainInfo * r ,
const char * name ,
2010-05-21 05:25:01 +04:00
struct dom_sid * sid )
2001-02-26 22:31:07 +03:00
{
2008-02-08 03:13:50 +03:00
init_lsa_StringLarge ( & r - > name , name ) ;
r - > sid = sid ;
2001-02-26 22:31:07 +03:00
}
2006-04-11 19:47:24 +04:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
initialize a lsa_DomainInfo structure .
2006-04-11 19:47:24 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
static void init_dom_query_5 ( struct lsa_DomainInfo * r ,
const char * name ,
2010-05-21 05:25:01 +04:00
struct dom_sid * sid )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:13:50 +03:00
init_lsa_StringLarge ( & r - > name , name ) ;
r - > sid = sid ;
2006-04-11 19:47:24 +04:00
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2006-02-16 04:06:21 +03:00
lookup_lsa_rids . Must be called as root for lookup_name to work .
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-02-16 04:06:21 +03:00
static NTSTATUS lookup_lsa_rids ( TALLOC_CTX * mem_ctx ,
2008-02-18 16:40:34 +03:00
struct lsa_RefDomainList * ref ,
struct lsa_TranslatedSid * prid ,
uint32_t num_entries ,
struct lsa_String * name ,
int flags ,
uint32_t * pmapped_count )
2001-02-26 22:31:07 +03:00
{
2006-02-18 03:27:31 +03:00
uint32 mapped_count , i ;
2001-02-26 22:31:07 +03:00
SMB_ASSERT ( num_entries < = MAX_LOOKUP_SIDS ) ;
2005-12-03 21:34:13 +03:00
mapped_count = 0 ;
2006-02-16 04:06:21 +03:00
* pmapped_count = 0 ;
2002-01-26 13:02:23 +03:00
2001-02-26 22:31:07 +03:00
for ( i = 0 ; i < num_entries ; i + + ) {
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2005-12-03 21:34:13 +03:00
uint32 rid ;
int dom_idx ;
2008-02-18 16:40:34 +03:00
const char * full_name ;
2005-12-10 14:22:01 +03:00
const char * domain ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType type = SID_NAME_UNKNOWN ;
2001-02-26 22:31:07 +03:00
/* Split name into domain and user component */
2009-10-21 04:45:21 +04:00
/* follow w2k8 behavior and return the builtin domain when no
* input has been passed in */
if ( name [ i ] . string ) {
full_name = name [ i ] . string ;
} else {
full_name = " BUILTIN " ;
2005-12-03 21:34:13 +03:00
}
2001-02-26 22:31:07 +03:00
2006-02-16 04:06:21 +03:00
DEBUG ( 5 , ( " lookup_lsa_rids: looking up name %s \n " , full_name ) ) ;
2001-02-26 22:31:07 +03:00
2005-12-03 21:34:13 +03:00
/* We can ignore the result of lookup_name, it will not touch
" type " if it ' s not successful */
2004-04-07 02:02:47 +04:00
2005-12-03 21:34:13 +03:00
lookup_name ( mem_ctx , full_name , flags , & domain , NULL ,
& sid , & type ) ;
2004-04-07 16:43:44 +04:00
2005-12-03 21:34:13 +03:00
switch ( type ) {
case SID_NAME_USER :
case SID_NAME_DOM_GRP :
case SID_NAME_DOMAIN :
case SID_NAME_ALIAS :
case SID_NAME_WKN_GRP :
2006-02-11 05:46:41 +03:00
DEBUG ( 5 , ( " init_lsa_rids: %s found \n " , full_name ) ) ;
2005-12-03 21:34:13 +03:00
/* Leave these unchanged */
break ;
default :
/* Don't hand out anything but the list above */
2006-02-11 05:46:41 +03:00
DEBUG ( 5 , ( " init_lsa_rids: %s not found \n " , full_name ) ) ;
2005-12-03 21:34:13 +03:00
type = SID_NAME_UNKNOWN ;
break ;
}
rid = 0 ;
dom_idx = - 1 ;
if ( type ! = SID_NAME_UNKNOWN ) {
2009-10-20 17:12:58 +04:00
if ( type = = SID_NAME_DOMAIN ) {
rid = ( uint32_t ) - 1 ;
} else {
sid_split_rid ( & sid , & rid ) ;
}
2008-02-18 16:40:34 +03:00
dom_idx = init_lsa_ref_domain_list ( mem_ctx , ref , domain , & sid ) ;
2005-12-03 21:34:13 +03:00
mapped_count + + ;
2001-02-26 22:31:07 +03:00
}
2008-12-08 20:03:01 +03:00
prid [ i ] . sid_type = type ;
prid [ i ] . rid = rid ;
prid [ i ] . sid_index = dom_idx ;
2001-02-26 22:31:07 +03:00
}
2002-01-26 13:02:23 +03:00
2006-02-16 04:06:21 +03:00
* pmapped_count = mapped_count ;
return NT_STATUS_OK ;
}
/***************************************************************************
lookup_lsa_sids . Must be called as root for lookup_name to work .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS lookup_lsa_sids ( TALLOC_CTX * mem_ctx ,
2008-02-18 18:57:02 +03:00
struct lsa_RefDomainList * ref ,
struct lsa_TranslatedSid3 * trans_sids ,
uint32_t num_entries ,
struct lsa_String * name ,
int flags ,
uint32 * pmapped_count )
2006-02-16 04:06:21 +03:00
{
2006-02-18 03:27:31 +03:00
uint32 mapped_count , i ;
2006-02-16 04:06:21 +03:00
SMB_ASSERT ( num_entries < = MAX_LOOKUP_SIDS ) ;
mapped_count = 0 ;
* pmapped_count = 0 ;
for ( i = 0 ; i < num_entries ; i + + ) {
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2006-02-16 04:06:21 +03:00
uint32 rid ;
int dom_idx ;
2008-02-18 18:57:02 +03:00
const char * full_name ;
2006-02-16 04:06:21 +03:00
const char * domain ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType type = SID_NAME_UNKNOWN ;
2006-02-16 04:06:21 +03:00
2008-03-04 13:06:02 +03:00
ZERO_STRUCT ( sid ) ;
2006-02-16 04:06:21 +03:00
/* Split name into domain and user component */
2008-02-18 18:57:02 +03:00
full_name = name [ i ] . string ;
2006-02-16 04:06:21 +03:00
if ( full_name = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
DEBUG ( 5 , ( " init_lsa_sids: looking up name %s \n " , full_name ) ) ;
/* We can ignore the result of lookup_name, it will not touch
" type " if it ' s not successful */
lookup_name ( mem_ctx , full_name , flags , & domain , NULL ,
& sid , & type ) ;
switch ( type ) {
case SID_NAME_USER :
case SID_NAME_DOM_GRP :
case SID_NAME_DOMAIN :
case SID_NAME_ALIAS :
case SID_NAME_WKN_GRP :
DEBUG ( 5 , ( " init_lsa_sids: %s found \n " , full_name ) ) ;
/* Leave these unchanged */
break ;
default :
/* Don't hand out anything but the list above */
DEBUG ( 5 , ( " init_lsa_sids: %s not found \n " , full_name ) ) ;
type = SID_NAME_UNKNOWN ;
break ;
}
rid = 0 ;
dom_idx = - 1 ;
if ( type ! = SID_NAME_UNKNOWN ) {
2010-05-21 05:25:01 +04:00
struct dom_sid domain_sid ;
2006-02-16 04:06:21 +03:00
sid_copy ( & domain_sid , & sid ) ;
sid_split_rid ( & domain_sid , & rid ) ;
2008-02-18 18:57:02 +03:00
dom_idx = init_lsa_ref_domain_list ( mem_ctx , ref , domain , & domain_sid ) ;
2006-02-16 04:06:21 +03:00
mapped_count + + ;
}
2008-02-18 18:57:02 +03:00
/* Initialize the lsa_TranslatedSid3 return. */
2006-02-16 04:06:21 +03:00
trans_sids [ i ] . sid_type = type ;
2008-02-18 18:57:02 +03:00
trans_sids [ i ] . sid = sid_dup_talloc ( mem_ctx , & sid ) ;
trans_sids [ i ] . sid_index = dom_idx ;
2006-02-16 04:06:21 +03:00
}
2005-12-03 21:34:13 +03:00
2006-02-16 04:06:21 +03:00
* pmapped_count = mapped_count ;
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
2010-05-18 12:29:34 +04:00
static NTSTATUS make_lsa_object_sd ( TALLOC_CTX * mem_ctx , struct security_descriptor * * sd , size_t * sd_size ,
2009-05-20 22:52:11 +04:00
const struct generic_mapping * map ,
2010-05-21 05:25:01 +04:00
struct dom_sid * sid , uint32_t sid_access )
2001-12-18 02:03:23 +03:00
{
2010-05-21 05:25:01 +04:00
struct dom_sid adm_sid ;
2010-05-18 05:25:38 +04:00
struct security_ace ace [ 5 ] ;
2009-05-20 22:52:11 +04:00
size_t i = 0 ;
2001-12-18 02:03:23 +03:00
2010-05-18 05:30:40 +04:00
struct security_acl * psa = NULL ;
2001-12-18 02:03:23 +03:00
2009-05-20 22:52:11 +04:00
/* READ|EXECUTE access for Everyone */
init_sec_ace ( & ace [ i + + ] , & global_sid_World , SEC_ACE_TYPE_ACCESS_ALLOWED ,
map - > generic_execute | map - > generic_read , 0 ) ;
2001-12-18 02:03:23 +03:00
2009-05-20 22:52:11 +04:00
/* Add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */
init_sec_ace ( & ace [ i + + ] , & global_sid_Builtin_Administrators ,
SEC_ACE_TYPE_ACCESS_ALLOWED , map - > generic_all , 0 ) ;
init_sec_ace ( & ace [ i + + ] , & global_sid_Builtin_Account_Operators ,
SEC_ACE_TYPE_ACCESS_ALLOWED , map - > generic_all , 0 ) ;
/* Add Full Access for Domain Admins */
2010-05-18 00:04:24 +04:00
sid_compose ( & adm_sid , get_global_sam_sid ( ) , DOMAIN_RID_ADMINS ) ;
2009-05-20 22:52:11 +04:00
init_sec_ace ( & ace [ i + + ] , & adm_sid , SEC_ACE_TYPE_ACCESS_ALLOWED ,
map - > generic_all , 0 ) ;
2001-12-18 02:03:23 +03:00
2009-05-20 22:52:11 +04:00
/* If we have a sid, give it some special access */
if ( sid ) {
init_sec_ace ( & ace [ i + + ] , sid , SEC_ACE_TYPE_ACCESS_ALLOWED ,
sid_access , 0 ) ;
}
2001-12-18 02:03:23 +03:00
2009-05-20 22:52:11 +04:00
if ( ( psa = make_sec_acl ( mem_ctx , NT4_ACL_REVISION , i , ace ) ) = = NULL )
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
2007-12-21 00:27:01 +03:00
if ( ( * sd = make_sec_desc ( mem_ctx , SECURITY_DESCRIPTOR_REVISION_1 ,
SEC_DESC_SELF_RELATIVE , & adm_sid , NULL , NULL ,
psa , sd_size ) ) = = NULL )
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
return NT_STATUS_OK ;
}
2002-08-17 19:34:15 +04:00
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-04 23:00:38 +03:00
_lsa_OpenPolicy2
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:00:38 +03:00
NTSTATUS _lsa_OpenPolicy2 ( pipes_struct * p ,
struct lsa_OpenPolicy2 * r )
2001-02-26 22:31:07 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * info ;
2010-05-18 12:29:34 +04:00
struct security_descriptor * psd = NULL ;
2001-12-18 02:03:23 +03:00
size_t sd_size ;
2008-02-04 23:00:38 +03:00
uint32 des_access = r - > in . access_mask ;
2001-12-18 02:03:23 +03:00
uint32 acc_granted ;
NTSTATUS status ;
2009-05-19 02:44:03 +04:00
/* Work out max allowed. */
2009-06-29 22:34:03 +04:00
map_max_allowed_access ( p - > server_info - > ptok ,
& p - > server_info - > utok ,
& des_access ) ;
2001-12-18 02:03:23 +03:00
/* map the generic bits to the lsa policy ones */
2009-05-20 22:52:11 +04:00
se_map_generic ( & des_access , & lsa_policy_mapping ) ;
2001-12-18 02:03:23 +03:00
/* get the generic lsa policy SD until we store it */
2009-05-20 22:52:11 +04:00
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size , & lsa_policy_mapping ,
NULL , 0 ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2001-12-18 02:03:23 +03:00
2009-05-19 02:44:03 +04:00
status = access_check_object ( psd , p - > server_info - > ptok ,
2009-10-27 01:37:21 +03:00
NULL , 0 , des_access ,
& acc_granted , " _lsa_OpenPolicy2 " ) ;
2008-10-31 20:51:45 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2009-05-19 02:44:03 +04:00
return status ;
2003-06-18 19:24:10 +04:00
}
2001-12-18 02:03:23 +03:00
/* associate the domain SID with the (unique) handle. */
2009-01-07 20:44:52 +03:00
info = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_info ) ;
2009-01-07 20:11:24 +03:00
if ( info = = NULL ) {
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
2009-01-07 20:11:24 +03:00
}
2001-12-18 02:03:23 +03:00
2002-07-15 14:35:28 +04:00
sid_copy ( & info - > sid , get_global_sam_sid ( ) ) ;
2001-12-18 02:03:23 +03:00
info - > access = acc_granted ;
2009-05-20 22:52:11 +04:00
info - > type = LSA_HANDLE_POLICY_TYPE ;
2001-02-26 22:31:07 +03:00
/* set up the LSA QUERY INFO response */
2009-01-07 20:44:52 +03:00
if ( ! create_policy_hnd ( p , r - > out . handle , info ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2001-02-26 22:31:07 +03:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
2008-02-04 23:00:16 +03:00
_lsa_OpenPolicy
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:00:16 +03:00
NTSTATUS _lsa_OpenPolicy ( pipes_struct * p ,
struct lsa_OpenPolicy * r )
2001-02-26 22:31:07 +03:00
{
2009-05-19 02:16:26 +04:00
struct lsa_OpenPolicy2 o ;
2001-12-18 02:03:23 +03:00
2009-05-19 02:16:26 +04:00
o . in . system_name = NULL ; /* should be ignored */
o . in . attr = r - > in . attr ;
o . in . access_mask = r - > in . access_mask ;
2001-12-18 02:03:23 +03:00
2009-05-19 02:16:26 +04:00
o . out . handle = r - > out . handle ;
2001-12-18 02:03:23 +03:00
2009-05-19 02:16:26 +04:00
return _lsa_OpenPolicy2 ( p , & o ) ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
2008-02-13 02:02:21 +03:00
_lsa_EnumTrustDom - this needs fixing to do more than return NULL ! JRA .
2002-07-15 14:35:28 +04:00
ufff , done : ) mimir
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-13 02:02:21 +03:00
NTSTATUS _lsa_EnumTrustDom ( pipes_struct * p ,
struct lsa_EnumTrustDom * r )
2001-02-26 22:31:07 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * info ;
2009-10-20 20:35:49 +04:00
uint32_t count ;
2006-02-04 01:19:41 +03:00
struct trustdom_info * * domains ;
2009-10-20 20:35:49 +04:00
struct lsa_DomainInfo * entries ;
2008-02-13 02:02:21 +03:00
int i ;
2002-07-15 14:35:28 +04:00
NTSTATUS nt_status ;
2001-02-26 22:31:07 +03:00
2008-02-13 02:02:21 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-06-16 15:27:16 +04:00
become_root ( ) ;
2009-10-20 20:35:49 +04:00
nt_status = pdb_enum_trusteddoms ( p - > mem_ctx , & count , & domains ) ;
2008-06-16 15:27:16 +04:00
unbecome_root ( ) ;
2002-07-15 14:35:28 +04:00
2006-02-04 01:19:41 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2002-07-15 14:35:28 +04:00
return nt_status ;
}
2009-10-20 20:35:49 +04:00
entries = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_DomainInfo , count ) ;
if ( ! entries ) {
return NT_STATUS_NO_MEMORY ;
}
2006-02-04 01:19:41 +03:00
2009-10-20 20:35:49 +04:00
for ( i = 0 ; i < count ; i + + ) {
init_lsa_StringLarge ( & entries [ i ] . name , domains [ i ] - > name ) ;
entries [ i ] . sid = & domains [ i ] - > sid ;
}
2006-02-04 01:19:41 +03:00
2009-10-20 20:35:49 +04:00
if ( * r - > in . resume_handle > = count ) {
* r - > out . resume_handle = - 1 ;
TALLOC_FREE ( entries ) ;
return NT_STATUS_NO_MORE_ENTRIES ;
2006-02-04 01:19:41 +03:00
}
2008-02-13 02:02:21 +03:00
2009-10-20 20:35:49 +04:00
/* return the rest, limit by max_size. Note that we
use the w2k3 element size value of 60 */
r - > out . domains - > count = count - * r - > in . resume_handle ;
r - > out . domains - > count = MIN ( r - > out . domains - > count ,
1 + ( r - > in . max_size / LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ) ) ;
2005-04-07 02:27:55 +04:00
2009-10-20 20:35:49 +04:00
r - > out . domains - > domains = entries + * r - > in . resume_handle ;
2001-02-26 22:31:07 +03:00
2009-10-20 20:35:49 +04:00
if ( r - > out . domains - > count < count - * r - > in . resume_handle ) {
* r - > out . resume_handle = * r - > in . resume_handle + r - > out . domains - > count ;
return STATUS_MORE_ENTRIES ;
2008-02-13 02:02:21 +03:00
}
2009-10-21 04:17:32 +04:00
/* according to MS-LSAD 3.1.4.7.8 output resume handle MUST
* always be larger than the previous input resume handle , in
* particular when hitting the last query it is vital to set the
* resume handle correctly to avoid infinite client loops , as
* seen e . g . with Windows XP SP3 when resume handle is 0 and
* status is NT_STATUS_OK - gd */
* r - > out . resume_handle = ( uint32_t ) - 1 ;
2009-10-20 20:35:49 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
2008-02-27 18:14:27 +03:00
# define LSA_AUDIT_NUM_CATEGORIES_NT4 7
# define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9
# define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-08 03:13:50 +03:00
_lsa_QueryInfoPolicy
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 03:13:50 +03:00
NTSTATUS _lsa_QueryInfoPolicy ( pipes_struct * p ,
struct lsa_QueryInfoPolicy * r )
2001-02-26 22:31:07 +03:00
{
2008-02-08 03:13:50 +03:00
NTSTATUS status = NT_STATUS_OK ;
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2010-05-21 05:25:01 +04:00
struct dom_sid domain_sid ;
2002-11-13 02:20:50 +03:00
const char * name ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sid = NULL ;
2008-02-08 03:13:50 +03:00
union lsa_PolicyInformation * info = NULL ;
2009-07-16 18:32:04 +04:00
uint32_t acc_required = 0 ;
2001-02-26 22:31:07 +03:00
2008-02-08 03:13:50 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2009-07-16 18:32:04 +04:00
switch ( r - > in . level ) {
case LSA_POLICY_INFO_AUDIT_LOG :
case LSA_POLICY_INFO_AUDIT_EVENTS :
acc_required = LSA_POLICY_VIEW_AUDIT_INFORMATION ;
break ;
case LSA_POLICY_INFO_DOMAIN :
acc_required = LSA_POLICY_VIEW_LOCAL_INFORMATION ;
break ;
case LSA_POLICY_INFO_PD :
acc_required = LSA_POLICY_GET_PRIVATE_INFORMATION ;
break ;
case LSA_POLICY_INFO_ACCOUNT_DOMAIN :
acc_required = LSA_POLICY_VIEW_LOCAL_INFORMATION ;
break ;
case LSA_POLICY_INFO_ROLE :
case LSA_POLICY_INFO_REPLICA :
acc_required = LSA_POLICY_VIEW_LOCAL_INFORMATION ;
break ;
case LSA_POLICY_INFO_QUOTA :
acc_required = LSA_POLICY_VIEW_LOCAL_INFORMATION ;
break ;
case LSA_POLICY_INFO_MOD :
case LSA_POLICY_INFO_AUDIT_FULL_SET :
/* according to MS-LSAD 3.1.4.4.3 */
return NT_STATUS_INVALID_PARAMETER ;
case LSA_POLICY_INFO_AUDIT_FULL_QUERY :
acc_required = LSA_POLICY_VIEW_AUDIT_INFORMATION ;
break ;
case LSA_POLICY_INFO_DNS :
case LSA_POLICY_INFO_DNS_INT :
case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN :
acc_required = LSA_POLICY_VIEW_LOCAL_INFORMATION ;
break ;
default :
break ;
}
if ( ! ( handle - > access & acc_required ) ) {
/* return NT_STATUS_ACCESS_DENIED; */
}
2008-02-08 03:13:50 +03:00
info = TALLOC_ZERO_P ( p - > mem_ctx , union lsa_PolicyInformation ) ;
if ( ! info ) {
return NT_STATUS_NO_MEMORY ;
}
switch ( r - > in . level ) {
2009-11-03 13:45:15 +03:00
/* according to MS-LSAD 3.1.4.4.3 */
case LSA_POLICY_INFO_MOD :
case LSA_POLICY_INFO_AUDIT_FULL_SET :
case LSA_POLICY_INFO_AUDIT_FULL_QUERY :
return NT_STATUS_INVALID_PARAMETER ;
case LSA_POLICY_INFO_AUDIT_LOG :
info - > audit_log . percent_full = 0 ;
info - > audit_log . maximum_log_size = 0 ;
info - > audit_log . retention_time = 0 ;
info - > audit_log . shutdown_in_progress = 0 ;
info - > audit_log . time_to_shutdown = 0 ;
info - > audit_log . next_audit_record = 0 ;
status = NT_STATUS_OK ;
break ;
case LSA_POLICY_INFO_PD :
info - > pd . name . string = NULL ;
status = NT_STATUS_OK ;
break ;
case LSA_POLICY_INFO_REPLICA :
info - > replica . source . string = NULL ;
info - > replica . account . string = NULL ;
status = NT_STATUS_OK ;
break ;
case LSA_POLICY_INFO_QUOTA :
info - > quota . paged_pool = 0 ;
info - > quota . non_paged_pool = 0 ;
info - > quota . min_wss = 0 ;
info - > quota . max_wss = 0 ;
info - > quota . pagefile = 0 ;
info - > quota . unknown = 0 ;
status = NT_STATUS_OK ;
break ;
2009-06-28 19:48:07 +04:00
case LSA_POLICY_INFO_AUDIT_EVENTS :
2001-02-26 22:31:07 +03:00
{
2006-04-11 19:47:24 +04:00
uint32 policy_def = LSA_AUDIT_POLICY_ALL ;
2008-02-08 03:13:50 +03:00
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_AUDIT_INFORMATION ) ) {
2008-02-08 03:13:50 +03:00
DEBUG ( 10 , ( " _lsa_QueryInfoPolicy: insufficient access rights \n " ) ) ;
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2006-04-11 19:47:24 +04:00
}
2001-12-18 02:03:23 +03:00
/* fake info: We audit everything. ;) */
2006-04-11 19:47:24 +04:00
2008-02-08 03:13:50 +03:00
info - > audit_events . auditing_mode = true ;
info - > audit_events . count = LSA_AUDIT_NUM_CATEGORIES ;
info - > audit_events . settings = TALLOC_ZERO_ARRAY ( p - > mem_ctx ,
enum lsa_PolicyAuditPolicy ,
info - > audit_events . count ) ;
if ( ! info - > audit_events . settings ) {
2001-12-18 02:03:23 +03:00
return NT_STATUS_NO_MEMORY ;
2008-02-08 03:13:50 +03:00
}
2006-04-11 19:47:24 +04:00
2008-02-08 03:13:50 +03:00
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_LOGON ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_PROCCESS_TRACKING ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_SYSTEM ] = policy_def ;
info - > audit_events . settings [ LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS ] = policy_def ;
2006-04-11 19:47:24 +04:00
2001-12-18 02:03:23 +03:00
break ;
2001-02-26 22:31:07 +03:00
}
2009-06-28 19:48:07 +04:00
case LSA_POLICY_INFO_DOMAIN :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
/* Request PolicyPrimaryDomainInformation. */
switch ( lp_server_role ( ) ) {
2001-02-26 22:31:07 +03:00
case ROLE_DOMAIN_PDC :
case ROLE_DOMAIN_BDC :
2003-05-07 12:21:06 +04:00
name = get_global_sam_name ( ) ;
2008-03-04 14:46:15 +03:00
sid = sid_dup_talloc ( p - > mem_ctx , get_global_sam_sid ( ) ) ;
if ( ! sid ) {
return NT_STATUS_NO_MEMORY ;
}
2001-02-26 22:31:07 +03:00
break ;
case ROLE_DOMAIN_MEMBER :
2002-11-13 02:20:50 +03:00
name = lp_workgroup ( ) ;
2001-04-22 03:06:59 +04:00
/* We need to return the Domain SID here. */
2008-03-04 14:46:15 +03:00
if ( secrets_fetch_domain_sid ( lp_workgroup ( ) , & domain_sid ) ) {
sid = sid_dup_talloc ( p - > mem_ctx , & domain_sid ) ;
if ( ! sid ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
2001-04-22 03:06:59 +04:00
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
2008-03-04 14:46:15 +03:00
}
2001-02-26 22:31:07 +03:00
break ;
2001-03-15 06:08:22 +03:00
case ROLE_STANDALONE :
2002-11-13 02:20:50 +03:00
name = lp_workgroup ( ) ;
2002-01-31 12:37:26 +03:00
sid = NULL ;
2001-03-15 06:08:22 +03:00
break ;
2001-03-15 05:49:06 +03:00
default :
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO ;
2001-02-26 22:31:07 +03:00
}
2008-02-08 03:13:50 +03:00
init_dom_query_3 ( & info - > domain , name , sid ) ;
2001-02-26 22:31:07 +03:00
break ;
2009-06-28 19:48:07 +04:00
case LSA_POLICY_INFO_ACCOUNT_DOMAIN :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
/* Request PolicyAccountDomainInformation. */
2003-05-07 12:21:06 +04:00
name = get_global_sam_name ( ) ;
sid = get_global_sam_sid ( ) ;
2008-02-08 03:13:50 +03:00
init_dom_query_5 ( & info - > account_domain , name , sid ) ;
2001-02-26 22:31:07 +03:00
break ;
2009-06-28 19:48:07 +04:00
case LSA_POLICY_INFO_ROLE :
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2001-04-22 03:06:59 +04:00
switch ( lp_server_role ( ) ) {
2001-02-26 22:31:07 +03:00
case ROLE_DOMAIN_BDC :
/*
* only a BDC is a backup controller
* of the domain , it controls .
*/
2009-04-02 20:48:15 +04:00
info - > role . role = LSA_ROLE_BACKUP ;
2001-02-26 22:31:07 +03:00
break ;
default :
/*
* any other role is a primary
* of the domain , it controls .
*/
2009-04-02 20:48:15 +04:00
info - > role . role = LSA_ROLE_PRIMARY ;
2008-02-08 03:13:50 +03:00
break ;
2001-02-26 22:31:07 +03:00
}
break ;
2009-07-16 18:28:11 +04:00
case LSA_POLICY_INFO_DNS :
case LSA_POLICY_INFO_DNS_INT : {
2009-06-29 01:07:00 +04:00
struct pdb_domain_info * dominfo ;
if ( ( pdb_capabilities ( ) & PDB_CAP_ADS ) = = 0 ) {
DEBUG ( 10 , ( " Not replying to LSA_POLICY_INFO_DNS "
" without ADS passdb backend \n " ) ) ;
status = NT_STATUS_INVALID_INFO_CLASS ;
break ;
}
dominfo = pdb_get_domain_info ( info ) ;
if ( dominfo = = NULL ) {
status = NT_STATUS_NO_MEMORY ;
break ;
}
init_lsa_StringLarge ( & info - > dns . name ,
dominfo - > name ) ;
init_lsa_StringLarge ( & info - > dns . dns_domain ,
dominfo - > dns_domain ) ;
init_lsa_StringLarge ( & info - > dns . dns_forest ,
dominfo - > dns_forest ) ;
info - > dns . domain_guid = dominfo - > guid ;
info - > dns . sid = & dominfo - > sid ;
break ;
}
2001-02-26 22:31:07 +03:00
default :
2008-02-08 03:13:50 +03:00
DEBUG ( 0 , ( " _lsa_QueryInfoPolicy: unknown info level in Lsa Query: %d \n " ,
r - > in . level ) ) ;
status = NT_STATUS_INVALID_INFO_CLASS ;
2001-02-26 22:31:07 +03:00
break ;
}
2008-02-08 03:13:50 +03:00
* r - > out . info = info ;
2001-02-26 22:31:07 +03:00
2008-02-08 03:13:50 +03:00
return status ;
2001-02-26 22:31:07 +03:00
}
2009-07-16 18:28:11 +04:00
/***************************************************************************
_lsa_QueryInfoPolicy2
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS _lsa_QueryInfoPolicy2 ( pipes_struct * p ,
struct lsa_QueryInfoPolicy2 * r2 )
{
struct lsa_QueryInfoPolicy r ;
if ( ( pdb_capabilities ( ) & PDB_CAP_ADS ) = = 0 ) {
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
ZERO_STRUCT ( r ) ;
r . in . handle = r2 - > in . handle ;
r . in . level = r2 - > in . level ;
r . out . info = r2 - > out . info ;
return _lsa_QueryInfoPolicy ( p , & r ) ;
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2006-02-11 02:52:53 +03:00
_lsa_lookup_sids_internal
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-02-11 02:52:53 +03:00
static NTSTATUS _lsa_lookup_sids_internal ( pipes_struct * p ,
2008-02-19 03:01:15 +03:00
TALLOC_CTX * mem_ctx ,
uint16_t level , /* input */
int num_sids , /* input */
struct lsa_SidPtr * sid , /* input */
struct lsa_RefDomainList * * pp_ref , /* input/output */
struct lsa_TranslatedName2 * * pp_names , /* input/output */
uint32_t * pp_mapped_count ) /* input/output */
2001-02-26 22:31:07 +03:00
{
2006-02-11 02:52:53 +03:00
NTSTATUS status ;
int i ;
2010-05-21 05:25:01 +04:00
const struct dom_sid * * sids = NULL ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * ref = NULL ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
struct lsa_dom_info * dom_infos = NULL ;
struct lsa_name_info * name_infos = NULL ;
2008-02-19 03:01:15 +03:00
struct lsa_TranslatedName2 * names = NULL ;
2002-03-30 00:50:21 +03:00
2006-02-11 02:52:53 +03:00
* pp_mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
* pp_names = NULL ;
2006-02-11 02:52:53 +03:00
* pp_ref = NULL ;
2007-05-05 02:01:26 +04:00
if ( num_sids = = 0 ) {
return NT_STATUS_OK ;
}
2010-05-21 05:25:01 +04:00
sids = TALLOC_ARRAY ( p - > mem_ctx , const struct dom_sid * , num_sids ) ;
2008-02-19 03:01:15 +03:00
ref = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
2006-02-04 01:19:41 +03:00
2007-06-09 04:13:07 +04:00
if ( sids = = NULL | | ref = = NULL ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_NO_MEMORY ;
2006-02-04 01:19:41 +03:00
}
for ( i = 0 ; i < num_sids ; i + + ) {
2008-02-19 03:01:15 +03:00
sids [ i ] = sid [ i ] . sid ;
2006-02-04 01:19:41 +03:00
}
2006-02-11 02:52:53 +03:00
status = lookup_sids ( p - > mem_ctx , num_sids , sids , level ,
2006-02-04 01:19:41 +03:00
& dom_infos , & name_infos ) ;
2006-02-11 02:52:53 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2006-02-04 01:19:41 +03:00
}
2008-02-19 03:01:15 +03:00
names = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedName2 , num_sids ) ;
if ( names = = NULL ) {
2007-05-05 02:01:26 +04:00
return NT_STATUS_NO_MEMORY ;
2004-05-21 22:06:27 +04:00
}
2006-02-04 01:19:41 +03:00
2008-10-24 04:01:16 +04:00
for ( i = 0 ; i < LSA_REF_DOMAIN_LIST_MULTIPLIER ; i + + ) {
2006-02-04 01:19:41 +03:00
if ( ! dom_infos [ i ] . valid ) {
break ;
}
2008-02-19 03:01:15 +03:00
if ( init_lsa_ref_domain_list ( mem_ctx , ref ,
dom_infos [ i ] . name ,
& dom_infos [ i ] . sid ) ! = i ) {
2006-02-04 01:19:41 +03:00
DEBUG ( 0 , ( " Domain %s mentioned twice?? \n " ,
dom_infos [ i ] . name ) ) ;
2006-02-11 02:52:53 +03:00
return NT_STATUS_INTERNAL_ERROR ;
2006-02-04 01:19:41 +03:00
}
}
for ( i = 0 ; i < num_sids ; i + + ) {
struct lsa_name_info * name = & name_infos [ i ] ;
if ( name - > type = = SID_NAME_UNKNOWN ) {
2007-12-16 00:00:39 +03:00
fstring tmp ;
2006-02-04 01:19:41 +03:00
name - > dom_idx = - 1 ;
2006-07-23 12:18:31 +04:00
/* Unknown sids should return the string
* representation of the SID . Windows 2003 behaves
* rather erratic here , in many cases it returns the
* RID as 8 bytes hex , in others it returns the full
* SID . We ( Jerry / VL ) could not figure out which the
* hard cases are , so leave it with the SID . */
2008-02-14 15:12:28 +03:00
name - > name = talloc_asprintf ( p - > mem_ctx , " %s " ,
2007-12-16 00:47:30 +03:00
sid_to_fstring ( tmp ,
sids [ i ] ) ) ;
2006-02-04 01:19:41 +03:00
if ( name - > name = = NULL ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_NO_MEMORY ;
2006-02-04 01:19:41 +03:00
}
} else {
mapped_count + = 1 ;
}
2008-12-08 20:03:01 +03:00
names [ i ] . sid_type = name - > type ;
names [ i ] . name . string = name - > name ;
names [ i ] . sid_index = name - > dom_idx ;
names [ i ] . unknown = 0 ;
2008-02-19 03:01:15 +03:00
}
2006-02-04 01:19:41 +03:00
2006-02-11 02:52:53 +03:00
status = NT_STATUS_NONE_MAPPED ;
2006-02-04 01:19:41 +03:00
if ( mapped_count > 0 ) {
2006-02-11 02:52:53 +03:00
status = ( mapped_count < num_sids ) ?
2006-02-04 01:19:41 +03:00
STATUS_SOME_UNMAPPED : NT_STATUS_OK ;
}
DEBUG ( 10 , ( " num_sids %d, mapped_count %d, status %s \n " ,
2006-02-11 02:52:53 +03:00
num_sids , mapped_count , nt_errstr ( status ) ) ) ;
* pp_mapped_count = mapped_count ;
2008-02-19 03:01:15 +03:00
* pp_names = names ;
2006-02-11 02:52:53 +03:00
* pp_ref = ref ;
return status ;
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids ( pipes_struct * p ,
struct lsa_LookupSids * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
NTSTATUS status ;
2006-02-11 02:52:53 +03:00
struct lsa_info * handle ;
2008-02-19 03:01:15 +03:00
int num_sids = r - > in . sids - > num_sids ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedName * names_out = NULL ;
struct lsa_TranslatedName2 * names = NULL ;
int i ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
if ( ( r - > in . level < 1 ) | | ( r - > in . level > 6 ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_INVALID_PARAMETER ;
}
2008-02-19 03:01:15 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_INVALID_HANDLE ;
}
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2006-02-11 02:52:53 +03:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2006-02-11 02:52:53 +03:00
return NT_STATUS_ACCESS_DENIED ;
}
if ( num_sids > MAX_LOOKUP_SIDS ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 5 , ( " _lsa_LookupSids: limit of %d exceeded, requested %d \n " ,
2006-02-11 02:52:53 +03:00
MAX_LOOKUP_SIDS , num_sids ) ) ;
return NT_STATUS_NONE_MAPPED ;
}
2008-02-19 03:01:15 +03:00
status = _lsa_lookup_sids_internal ( p ,
p - > mem_ctx ,
r - > in . level ,
num_sids ,
r - > in . sids - > sids ,
& domains ,
& names ,
& mapped_count ) ;
2006-02-11 02:52:53 +03:00
2009-04-16 03:42:35 +04:00
/* Only return here when there is a real error.
NT_STATUS_NONE_MAPPED is a special case as it indicates that none of
the requested sids could be resolved . Older versions of XP ( pre SP3 )
rely that we return with the string representations of those SIDs in
that case . If we don ' t , XP crashes - Guenther
*/
if ( NT_STATUS_IS_ERR ( status ) & &
! NT_STATUS_EQUAL ( status , NT_STATUS_NONE_MAPPED ) ) {
2009-03-24 13:07:16 +03:00
return status ;
}
2008-02-19 03:01:15 +03:00
/* Convert from lsa_TranslatedName2 to lsa_TranslatedName */
names_out = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedName ,
num_sids ) ;
if ( ! names_out ) {
return NT_STATUS_NO_MEMORY ;
}
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
for ( i = 0 ; i < num_sids ; i + + ) {
names_out [ i ] . sid_type = names [ i ] . sid_type ;
names_out [ i ] . name = names [ i ] . name ;
names_out [ i ] . sid_index = names [ i ] . sid_index ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
* r - > out . domains = domains ;
r - > out . names - > count = num_sids ;
r - > out . names - > names = names_out ;
* r - > out . count = mapped_count ;
return status ;
2006-02-11 02:52:53 +03:00
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids2
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids2 ( pipes_struct * p ,
struct lsa_LookupSids2 * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
NTSTATUS status ;
2006-02-11 02:52:53 +03:00
struct lsa_info * handle ;
2008-02-19 03:01:15 +03:00
int num_sids = r - > in . sids - > num_sids ;
2006-02-11 02:52:53 +03:00
uint32 mapped_count = 0 ;
2008-02-19 03:01:15 +03:00
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedName2 * names = NULL ;
bool check_policy = true ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
switch ( p - > hdr_req . opnum ) {
case NDR_LSA_LOOKUPSIDS3 :
check_policy = false ;
break ;
case NDR_LSA_LOOKUPSIDS2 :
default :
check_policy = true ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
if ( ( r - > in . level < 1 ) | | ( r - > in . level > 6 ) ) {
return NT_STATUS_INVALID_PARAMETER ;
2006-02-11 02:52:53 +03:00
}
2008-02-19 03:01:15 +03:00
if ( check_policy ) {
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
return NT_STATUS_INVALID_HANDLE ;
}
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-19 03:01:15 +03:00
return NT_STATUS_ACCESS_DENIED ;
}
2006-02-11 02:52:53 +03:00
}
if ( num_sids > MAX_LOOKUP_SIDS ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 5 , ( " _lsa_LookupSids2: limit of %d exceeded, requested %d \n " ,
2006-02-11 02:52:53 +03:00
MAX_LOOKUP_SIDS , num_sids ) ) ;
return NT_STATUS_NONE_MAPPED ;
}
2008-02-19 03:01:15 +03:00
status = _lsa_lookup_sids_internal ( p ,
p - > mem_ctx ,
r - > in . level ,
num_sids ,
r - > in . sids - > sids ,
& domains ,
& names ,
& mapped_count ) ;
2006-02-11 02:52:53 +03:00
2008-02-19 03:01:15 +03:00
* r - > out . domains = domains ;
r - > out . names - > count = num_sids ;
r - > out . names - > names = names ;
* r - > out . count = mapped_count ;
return status ;
2006-02-11 02:52:53 +03:00
}
/***************************************************************************
2008-02-19 03:01:15 +03:00
_lsa_LookupSids3
2006-02-11 02:52:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-19 03:01:15 +03:00
NTSTATUS _lsa_LookupSids3 ( pipes_struct * p ,
struct lsa_LookupSids3 * r )
2006-02-11 02:52:53 +03:00
{
2008-02-19 03:01:15 +03:00
struct lsa_LookupSids2 q ;
2006-02-11 02:52:53 +03:00
2007-10-11 00:34:30 +04:00
/* No policy handle on this call. Restrict to crypto connections. */
if ( p - > auth . auth_type ! = PIPE_AUTH_TYPE_SCHANNEL ) {
2008-02-19 03:01:15 +03:00
DEBUG ( 0 , ( " _lsa_LookupSids3: client %s not using schannel for netlogon \n " ,
2007-10-11 00:34:30 +04:00
get_remote_machine_name ( ) ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2006-07-22 23:44:17 +04:00
2008-02-19 03:01:15 +03:00
q . in . handle = NULL ;
q . in . sids = r - > in . sids ;
q . in . level = r - > in . level ;
2009-09-11 15:55:44 +04:00
q . in . lookup_options = r - > in . lookup_options ;
q . in . client_revision = r - > in . client_revision ;
2008-02-19 03:01:15 +03:00
q . in . names = r - > in . names ;
q . in . count = r - > in . count ;
2006-07-22 23:44:17 +04:00
2008-02-19 03:01:15 +03:00
q . out . domains = r - > out . domains ;
q . out . names = r - > out . names ;
q . out . count = r - > out . count ;
2007-10-11 00:34:30 +04:00
2008-02-19 03:01:15 +03:00
return _lsa_LookupSids2 ( p , & q ) ;
2001-02-26 22:31:07 +03:00
}
2008-02-19 03:01:15 +03:00
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-10-27 01:28:30 +03:00
static int lsa_lookup_level_to_flags ( enum lsa_LookupNamesLevel level )
2007-12-12 20:03:20 +03:00
{
int flags ;
switch ( level ) {
2009-10-27 01:28:30 +03:00
case LSA_LOOKUP_NAMES_ALL : /* 1 */
2007-12-12 20:03:20 +03:00
flags = LOOKUP_NAME_ALL ;
break ;
2009-10-27 01:28:30 +03:00
case LSA_LOOKUP_NAMES_DOMAINS_ONLY : /* 2 */
2007-12-12 20:03:20 +03:00
flags = LOOKUP_NAME_DOMAIN | LOOKUP_NAME_REMOTE | LOOKUP_NAME_ISOLATED ;
break ;
2009-10-27 01:28:30 +03:00
case LSA_LOOKUP_NAMES_PRIMARY_DOMAIN_ONLY : /* 3 */
2007-12-12 20:03:20 +03:00
flags = LOOKUP_NAME_DOMAIN | LOOKUP_NAME_ISOLATED ;
break ;
2009-10-27 01:28:30 +03:00
case LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY : /* 4 */
case LSA_LOOKUP_NAMES_FOREST_TRUSTS_ONLY : /* 5 */
case LSA_LOOKUP_NAMES_UPLEVEL_TRUSTS_ONLY2 : /* 6 */
case LSA_LOOKUP_NAMES_RODC_REFERRAL_TO_FULL_DC : /* 7 */
2007-12-12 20:03:20 +03:00
default :
flags = LOOKUP_NAME_NONE ;
break ;
}
return flags ;
}
2001-02-26 22:31:07 +03:00
/***************************************************************************
2008-02-18 16:40:34 +03:00
_lsa_LookupNames
2001-02-26 22:31:07 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 16:40:34 +03:00
NTSTATUS _lsa_LookupNames ( pipes_struct * p ,
struct lsa_LookupNames * r )
2001-02-26 22:31:07 +03:00
{
2008-02-18 16:40:34 +03:00
NTSTATUS status = NT_STATUS_NONE_MAPPED ;
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2008-02-18 16:40:34 +03:00
struct lsa_String * names = r - > in . names ;
uint32 num_entries = r - > in . num_names ;
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedSid * rids = NULL ;
2001-02-26 22:31:07 +03:00
uint32 mapped_count = 0 ;
2005-12-03 21:34:13 +03:00
int flags = 0 ;
2001-02-26 22:31:07 +03:00
2002-01-26 13:02:23 +03:00
if ( num_entries > MAX_LOOKUP_SIDS ) {
num_entries = MAX_LOOKUP_SIDS ;
2008-02-18 16:40:34 +03:00
DEBUG ( 5 , ( " _lsa_LookupNames: truncating name lookup list to %d \n " ,
num_entries ) ) ;
2002-01-26 13:02:23 +03:00
}
2008-02-14 15:12:28 +03:00
2008-02-18 16:40:34 +03:00
flags = lsa_lookup_level_to_flags ( r - > in . level ) ;
2005-12-03 21:34:13 +03:00
2008-02-18 16:40:34 +03:00
domains = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
if ( ! domains ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
}
if ( num_entries ) {
2008-02-18 16:40:34 +03:00
rids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid ,
num_entries ) ;
2007-04-30 05:17:34 +04:00
if ( ! rids ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
rids = NULL ;
}
2001-03-01 07:01:23 +03:00
2008-02-18 16:40:34 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
status = NT_STATUS_INVALID_HANDLE ;
2002-03-30 00:50:21 +03:00
goto done ;
}
2002-03-29 23:37:56 +03:00
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-18 16:40:34 +03:00
status = NT_STATUS_ACCESS_DENIED ;
2002-03-30 00:50:21 +03:00
goto done ;
}
2002-03-29 23:37:56 +03:00
2005-12-03 21:34:13 +03:00
/* set up the LSA Lookup RIDs response */
2006-02-16 04:06:21 +03:00
become_root ( ) ; /* lookup_name can require root privs */
2008-02-18 16:40:34 +03:00
status = lookup_lsa_rids ( p - > mem_ctx , domains , rids , num_entries ,
names , flags , & mapped_count ) ;
2006-02-16 04:06:21 +03:00
unbecome_root ( ) ;
2002-03-30 00:50:21 +03:00
done :
2008-02-18 16:40:34 +03:00
if ( NT_STATUS_IS_OK ( status ) & & ( num_entries ! = 0 ) ) {
if ( mapped_count = = 0 ) {
status = NT_STATUS_NONE_MAPPED ;
} else if ( mapped_count ! = num_entries ) {
status = STATUS_SOME_UNMAPPED ;
}
2004-05-26 22:27:16 +04:00
}
2001-02-26 22:31:07 +03:00
2008-03-04 15:16:02 +03:00
* r - > out . count = mapped_count ;
2008-02-18 16:40:34 +03:00
* r - > out . domains = domains ;
r - > out . sids - > sids = rids ;
2008-03-04 15:16:02 +03:00
r - > out . sids - > count = num_entries ;
2008-02-18 16:40:34 +03:00
return status ;
2001-02-26 22:31:07 +03:00
}
2006-02-11 07:25:06 +03:00
/***************************************************************************
2008-02-18 16:40:34 +03:00
_lsa_LookupNames2
2006-02-11 07:25:06 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 16:40:34 +03:00
NTSTATUS _lsa_LookupNames2 ( pipes_struct * p ,
struct lsa_LookupNames2 * r )
2006-02-11 07:25:06 +03:00
{
2008-02-18 16:40:34 +03:00
NTSTATUS status ;
struct lsa_LookupNames q ;
struct lsa_TransSidArray2 * sid_array2 = r - > in . sids ;
struct lsa_TransSidArray * sid_array = NULL ;
uint32_t i ;
2006-02-11 07:25:06 +03:00
2008-02-18 16:40:34 +03:00
sid_array = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_TransSidArray ) ;
if ( ! sid_array ) {
2006-06-21 04:17:14 +04:00
return NT_STATUS_NO_MEMORY ;
2006-06-20 13:16:53 +04:00
}
2008-02-18 16:40:34 +03:00
q . in . handle = r - > in . handle ;
q . in . num_names = r - > in . num_names ;
q . in . names = r - > in . names ;
q . in . level = r - > in . level ;
q . in . sids = sid_array ;
q . in . count = r - > in . count ;
/* we do not know what this is for */
/* = r->in.unknown1; */
/* = r->in.unknown2; */
2007-04-30 05:17:34 +04:00
2008-02-18 16:40:34 +03:00
q . out . domains = r - > out . domains ;
q . out . sids = sid_array ;
q . out . count = r - > out . count ;
2006-02-11 07:25:06 +03:00
2008-02-18 16:40:34 +03:00
status = _lsa_LookupNames ( p , & q ) ;
2006-02-11 07:25:06 +03:00
2009-05-11 20:27:40 +04:00
sid_array2 - > count = sid_array - > count ;
2008-02-18 16:40:34 +03:00
sid_array2 - > sids = TALLOC_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid2 , sid_array - > count ) ;
if ( ! sid_array2 - > sids ) {
return NT_STATUS_NO_MEMORY ;
2006-02-11 07:25:06 +03:00
}
2008-02-18 16:40:34 +03:00
for ( i = 0 ; i < sid_array - > count ; i + + ) {
sid_array2 - > sids [ i ] . sid_type = sid_array - > sids [ i ] . sid_type ;
sid_array2 - > sids [ i ] . rid = sid_array - > sids [ i ] . rid ;
sid_array2 - > sids [ i ] . sid_index = sid_array - > sids [ i ] . sid_index ;
sid_array2 - > sids [ i ] . unknown = 0 ;
2006-02-11 07:25:06 +03:00
}
2008-02-18 16:40:34 +03:00
r - > out . sids = sid_array2 ;
return status ;
2006-02-11 07:25:06 +03:00
}
2006-02-11 08:36:27 +03:00
/***************************************************************************
2008-02-18 18:57:02 +03:00
_lsa_LookupNames3
2006-02-11 08:36:27 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 18:57:02 +03:00
NTSTATUS _lsa_LookupNames3 ( pipes_struct * p ,
struct lsa_LookupNames3 * r )
2006-02-11 08:36:27 +03:00
{
2008-02-18 18:57:02 +03:00
NTSTATUS status ;
2006-02-16 04:06:21 +03:00
struct lsa_info * handle ;
2008-02-18 18:57:02 +03:00
struct lsa_String * names = r - > in . names ;
uint32 num_entries = r - > in . num_names ;
struct lsa_RefDomainList * domains = NULL ;
struct lsa_TranslatedSid3 * trans_sids = NULL ;
2006-02-16 04:06:21 +03:00
uint32 mapped_count = 0 ;
int flags = 0 ;
2008-02-18 18:57:02 +03:00
bool check_policy = true ;
switch ( p - > hdr_req . opnum ) {
case NDR_LSA_LOOKUPNAMES4 :
check_policy = false ;
break ;
case NDR_LSA_LOOKUPNAMES3 :
default :
check_policy = true ;
}
2006-02-16 04:06:21 +03:00
if ( num_entries > MAX_LOOKUP_SIDS ) {
num_entries = MAX_LOOKUP_SIDS ;
2008-02-18 18:57:02 +03:00
DEBUG ( 5 , ( " _lsa_LookupNames3: truncating name lookup list to %d \n " , num_entries ) ) ;
2006-02-16 04:06:21 +03:00
}
2008-02-14 15:12:28 +03:00
2006-02-16 04:06:21 +03:00
/* Probably the lookup_level is some sort of bitmask. */
2008-02-18 18:57:02 +03:00
if ( r - > in . level = = 1 ) {
2006-02-16 04:06:21 +03:00
flags = LOOKUP_NAME_ALL ;
}
2008-02-18 18:57:02 +03:00
domains = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_RefDomainList ) ;
if ( ! domains ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
}
2008-02-18 18:57:02 +03:00
2007-04-30 05:17:34 +04:00
if ( num_entries ) {
2008-02-18 18:57:02 +03:00
trans_sids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_TranslatedSid3 ,
num_entries ) ;
2007-04-30 05:17:34 +04:00
if ( ! trans_sids ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
trans_sids = NULL ;
}
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
if ( check_policy ) {
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) ) {
status = NT_STATUS_INVALID_HANDLE ;
goto done ;
}
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
2008-02-18 18:57:02 +03:00
status = NT_STATUS_ACCESS_DENIED ;
goto done ;
}
2006-02-16 04:06:21 +03:00
}
/* set up the LSA Lookup SIDs response */
become_root ( ) ; /* lookup_name can require root privs */
2008-02-18 18:57:02 +03:00
status = lookup_lsa_sids ( p - > mem_ctx , domains , trans_sids , num_entries ,
names , flags , & mapped_count ) ;
2006-02-16 04:06:21 +03:00
unbecome_root ( ) ;
done :
2008-02-18 18:57:02 +03:00
if ( NT_STATUS_IS_OK ( status ) ) {
2006-02-16 04:06:21 +03:00
if ( mapped_count = = 0 ) {
2008-02-18 18:57:02 +03:00
status = NT_STATUS_NONE_MAPPED ;
2006-02-16 04:06:21 +03:00
} else if ( mapped_count ! = num_entries ) {
2008-02-18 18:57:02 +03:00
status = STATUS_SOME_UNMAPPED ;
2006-02-16 04:06:21 +03:00
}
}
2008-03-04 15:19:38 +03:00
* r - > out . count = mapped_count ;
2008-02-18 18:57:02 +03:00
* r - > out . domains = domains ;
r - > out . sids - > sids = trans_sids ;
2008-03-04 15:19:38 +03:00
r - > out . sids - > count = num_entries ;
2008-02-18 18:57:02 +03:00
return status ;
2006-02-11 08:36:27 +03:00
}
/***************************************************************************
2008-02-18 18:57:02 +03:00
_lsa_LookupNames4
2006-02-11 08:36:27 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-18 18:57:02 +03:00
NTSTATUS _lsa_LookupNames4 ( pipes_struct * p ,
struct lsa_LookupNames4 * r )
2006-02-11 08:36:27 +03:00
{
2008-02-18 18:57:02 +03:00
struct lsa_LookupNames3 q ;
2006-02-16 04:06:21 +03:00
/* No policy handle on this call. Restrict to crypto connections. */
if ( p - > auth . auth_type ! = PIPE_AUTH_TYPE_SCHANNEL ) {
DEBUG ( 0 , ( " _lsa_lookup_names4: client %s not using schannel for netlogon \n " ,
get_remote_machine_name ( ) ) ) ;
return NT_STATUS_INVALID_PARAMETER ;
}
2008-02-18 18:57:02 +03:00
q . in . handle = NULL ;
q . in . num_names = r - > in . num_names ;
q . in . names = r - > in . names ;
q . in . level = r - > in . level ;
2008-10-15 21:33:16 +04:00
q . in . lookup_options = r - > in . lookup_options ;
q . in . client_revision = r - > in . client_revision ;
2008-02-18 18:57:02 +03:00
q . in . sids = r - > in . sids ;
q . in . count = r - > in . count ;
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
q . out . domains = r - > out . domains ;
q . out . sids = r - > out . sids ;
q . out . count = r - > out . count ;
2006-02-16 04:06:21 +03:00
2008-02-18 18:57:02 +03:00
return _lsa_LookupNames3 ( p , & q ) ;
2006-02-11 08:36:27 +03:00
}
2006-02-11 07:25:06 +03:00
2001-02-26 22:31:07 +03:00
/***************************************************************************
_lsa_close . Also weird - needs to check if lsa handle is correct . JRA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_Close ( pipes_struct * p , struct lsa_Close * r )
2001-02-26 22:31:07 +03:00
{
2007-01-18 13:18:59 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , NULL ) ) {
2001-03-11 03:32:10 +03:00
return NT_STATUS_INVALID_HANDLE ;
2006-02-16 04:06:21 +03:00
}
2001-03-11 03:32:10 +03:00
2007-01-18 13:18:59 +03:00
close_policy_hnd ( p , r - > in . handle ) ;
2008-03-03 20:12:26 +03:00
ZERO_STRUCTP ( r - > out . handle ) ;
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-02-26 22:31:07 +03:00
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenSecret ( pipes_struct * p , struct lsa_OpenSecret * r )
2001-02-26 22:31:07 +03:00
{
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
2001-06-30 03:12:55 +04:00
2005-05-31 17:46:45 +04:00
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenTrustedDomain ( pipes_struct * p , struct lsa_OpenTrustedDomain * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomain ( pipes_struct * p , struct lsa_CreateTrustedDomain * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateSecret ( pipes_struct * p , struct lsa_CreateSecret * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetSecret ( pipes_struct * p , struct lsa_SetSecret * r )
2005-05-31 17:46:45 +04:00
{
return NT_STATUS_ACCESS_DENIED ;
}
/***************************************************************************
2008-02-05 00:05:48 +03:00
_lsa_DeleteObject
2005-05-31 17:46:45 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-05 00:05:48 +03:00
NTSTATUS _lsa_DeleteObject ( pipes_struct * p ,
struct lsa_DeleteObject * r )
2005-05-31 17:46:45 +04:00
{
2009-05-18 23:00:29 +04:00
NTSTATUS status ;
struct lsa_info * info = NULL ;
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) ) {
return NT_STATUS_INVALID_HANDLE ;
}
2009-05-20 22:52:11 +04:00
if ( ! ( info - > access & STD_RIGHT_DELETE_ACCESS ) ) {
2009-05-18 23:00:29 +04:00
return NT_STATUS_ACCESS_DENIED ;
}
2009-07-17 15:44:55 +04:00
switch ( info - > type ) {
case LSA_HANDLE_ACCOUNT_TYPE :
status = privilege_delete_account ( & info - > sid ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 10 , ( " _lsa_DeleteObject: privilege_delete_account gave: %s \n " ,
nt_errstr ( status ) ) ) ;
return status ;
}
break ;
default :
return NT_STATUS_INVALID_HANDLE ;
2009-05-18 23:00:29 +04:00
}
2009-07-17 15:44:55 +04:00
close_policy_hnd ( p , r - > in . handle ) ;
ZERO_STRUCTP ( r - > out . handle ) ;
2009-05-18 23:00:29 +04:00
return status ;
2005-05-31 17:46:45 +04:00
}
2001-07-09 22:32:54 +04:00
/***************************************************************************
2008-02-11 12:19:54 +03:00
_lsa_EnumPrivs
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-11 12:19:54 +03:00
NTSTATUS _lsa_EnumPrivs ( pipes_struct * p ,
struct lsa_EnumPrivs * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2001-07-09 22:32:54 +04:00
uint32 i ;
2008-02-11 12:19:54 +03:00
uint32 enum_context = * r - > in . resume_handle ;
2005-09-30 21:13:37 +04:00
int num_privs = count_all_privileges ( ) ;
2008-02-11 12:19:54 +03:00
struct lsa_PrivEntry * entries = NULL ;
2005-01-17 18:23:11 +03:00
LUID_ATTR luid ;
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
/* remember that the enum_context starts at 0 and not 1 */
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
if ( enum_context > = num_privs )
2002-03-29 23:37:56 +03:00
return NT_STATUS_NO_MORE_ENTRIES ;
2008-02-14 03:53:42 +03:00
DEBUG ( 10 , ( " _lsa_EnumPrivs: enum_context:%d total entries:%d \n " ,
2005-01-13 21:20:37 +03:00
enum_context , num_privs ) ) ;
2008-02-14 03:53:42 +03:00
2008-02-11 12:19:54 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights
2005-01-13 21:20:37 +03:00
I don ' t know if it ' s the right one . not documented . */
2001-12-18 02:03:23 +03:00
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2007-04-30 05:17:34 +04:00
if ( num_privs ) {
2008-02-11 12:19:54 +03:00
entries = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_PrivEntry , num_privs ) ;
if ( ! entries ) {
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
2008-02-11 12:19:54 +03:00
}
2007-04-30 05:17:34 +04:00
} else {
entries = NULL ;
}
2005-01-13 21:20:37 +03:00
for ( i = 0 ; i < num_privs ; i + + ) {
if ( i < enum_context ) {
2008-02-11 12:19:54 +03:00
init_lsa_StringLarge ( & entries [ i ] . name , NULL ) ;
entries [ i ] . luid . low = 0 ;
entries [ i ] . luid . high = 0 ;
2001-11-23 02:50:16 +03:00
} else {
2008-02-11 12:19:54 +03:00
init_lsa_StringLarge ( & entries [ i ] . name , privs [ i ] . name ) ;
2005-01-17 18:23:11 +03:00
luid = get_privilege_luid ( & privs [ i ] . se_priv ) ;
2008-02-11 12:19:54 +03:00
entries [ i ] . luid . low = luid . luid . low ;
entries [ i ] . luid . high = luid . luid . high ;
2001-11-23 02:50:16 +03:00
}
2001-07-09 22:32:54 +04:00
}
2005-01-13 21:20:37 +03:00
enum_context = num_privs ;
2008-02-11 12:19:54 +03:00
* r - > out . resume_handle = enum_context ;
r - > out . privs - > count = num_privs ;
r - > out . privs - > privs = entries ;
2001-07-09 22:32:54 +04:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-11 13:57:29 +03:00
_lsa_LookupPrivDisplayName
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-11 13:57:29 +03:00
NTSTATUS _lsa_LookupPrivDisplayName ( pipes_struct * p ,
struct lsa_LookupPrivDisplayName * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2005-01-17 18:23:11 +03:00
const char * description ;
2008-02-11 13:57:29 +03:00
struct lsa_StringLarge * lsa_name ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2001-12-18 02:03:23 +03:00
/*
* I don ' t know if it ' s the right one . not documented .
*/
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-11 13:57:29 +03:00
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: name = %s \n " , r - > in . name - > string ) ) ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
description = get_privilege_dispname ( r - > in . name - > string ) ;
if ( ! description ) {
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: doesn't exist \n " ) ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
DEBUG ( 10 , ( " _lsa_LookupPrivDisplayName: display name = %s \n " , description ) ) ;
2001-07-09 22:32:54 +04:00
2008-02-11 13:57:29 +03:00
lsa_name = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_StringLarge ) ;
if ( ! lsa_name ) {
return NT_STATUS_NO_MEMORY ;
2001-11-22 20:19:59 +03:00
}
2008-02-11 13:57:29 +03:00
init_lsa_StringLarge ( lsa_name , description ) ;
* r - > out . returned_language_id = r - > in . language_id ;
* r - > out . disp_name = lsa_name ;
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-14 03:16:03 +03:00
_lsa_EnumAccounts
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 03:16:03 +03:00
NTSTATUS _lsa_EnumAccounts ( pipes_struct * p ,
struct lsa_EnumAccounts * r )
2001-07-09 22:32:54 +04:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sid_list ;
2005-01-13 21:20:37 +03:00
int i , j , num_entries ;
2008-02-14 03:16:03 +03:00
NTSTATUS status ;
struct lsa_SidPtr * sids = NULL ;
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-02-27 17:49:31 +03:00
if ( ! ( handle - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) )
2001-12-18 02:03:23 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-13 21:20:37 +03:00
sid_list = NULL ;
num_entries = 0 ;
/* The only way we can currently find out all the SIDs that have been
privileged is to scan all privileges */
2008-02-14 03:16:03 +03:00
status = privilege_enumerate_accounts ( & sid_list , & num_entries ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2003-11-24 20:31:38 +03:00
}
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
if ( * r - > in . resume_handle > = num_entries ) {
2001-11-23 18:11:22 +03:00
return NT_STATUS_NO_MORE_ENTRIES ;
2008-02-14 03:16:03 +03:00
}
2001-11-23 18:11:22 +03:00
2008-02-14 03:16:03 +03:00
if ( num_entries - * r - > in . resume_handle ) {
sids = TALLOC_ZERO_ARRAY ( p - > mem_ctx , struct lsa_SidPtr ,
num_entries - * r - > in . resume_handle ) ;
if ( ! sids ) {
2009-04-02 20:47:51 +04:00
talloc_free ( sid_list ) ;
2007-04-30 05:17:34 +04:00
return NT_STATUS_NO_MEMORY ;
}
2007-08-04 14:18:33 +04:00
2008-02-14 03:16:03 +03:00
for ( i = * r - > in . resume_handle , j = 0 ; i < num_entries ; i + + , j + + ) {
sids [ j ] . sid = sid_dup_talloc ( p - > mem_ctx , & sid_list [ i ] ) ;
if ( ! sids [ j ] . sid ) {
2009-04-02 20:47:51 +04:00
talloc_free ( sid_list ) ;
2008-02-14 03:16:03 +03:00
return NT_STATUS_NO_MEMORY ;
}
2007-08-04 14:18:33 +04:00
}
2001-07-09 22:32:54 +04:00
}
2007-04-29 23:20:48 +04:00
talloc_free ( sid_list ) ;
2001-07-09 22:32:54 +04:00
2008-02-14 03:16:03 +03:00
* r - > out . resume_handle = num_entries ;
r - > out . sids - > num_sids = num_entries ;
r - > out . sids - > sids = sids ;
2001-07-09 22:32:54 +04:00
2001-08-27 23:46:22 +04:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
2008-02-11 22:29:31 +03:00
/***************************************************************************
_lsa_GetUserName
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-07-09 22:32:54 +04:00
2008-02-11 22:29:31 +03:00
NTSTATUS _lsa_GetUserName ( pipes_struct * p ,
struct lsa_GetUserName * r )
2001-06-30 03:12:55 +04:00
{
2006-07-15 21:55:01 +04:00
const char * username , * domname ;
2008-02-11 22:29:31 +03:00
struct lsa_String * account_name = NULL ;
struct lsa_String * authority_name = NULL ;
2008-10-21 03:19:49 +04:00
if ( r - > in . account_name & &
* r - > in . account_name ) {
return NT_STATUS_INVALID_PARAMETER ;
}
if ( r - > in . authority_name & &
* r - > in . authority_name ) {
return NT_STATUS_INVALID_PARAMETER ;
}
2008-06-24 17:24:08 +04:00
if ( p - > server_info - > guest ) {
2006-07-15 21:55:01 +04:00
/*
* I ' m 99 % sure this is not the right place to do this ,
* global_sid_Anonymous should probably be put into the token
* instead of the guest id - - vl
*/
if ( ! lookup_sid ( p - > mem_ctx , & global_sid_Anonymous ,
& domname , & username , NULL ) ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
2008-06-24 17:24:08 +04:00
username = p - > server_info - > sanitized_username ;
2010-05-27 11:41:56 +04:00
domname = p - > server_info - > info3 - > base . domain . string ;
2006-07-15 21:55:01 +04:00
}
2001-06-30 03:12:55 +04:00
2008-10-21 14:26:05 +04:00
account_name = TALLOC_P ( p - > mem_ctx , struct lsa_String ) ;
2008-02-11 22:29:31 +03:00
if ( ! account_name ) {
return NT_STATUS_NO_MEMORY ;
}
2008-10-21 03:19:49 +04:00
init_lsa_String ( account_name , username ) ;
2001-06-30 03:12:55 +04:00
2008-10-21 03:19:49 +04:00
if ( r - > out . authority_name ) {
2008-10-21 14:26:05 +04:00
authority_name = TALLOC_P ( p - > mem_ctx , struct lsa_String ) ;
2008-10-21 03:19:49 +04:00
if ( ! authority_name ) {
return NT_STATUS_NO_MEMORY ;
}
init_lsa_String ( authority_name , domname ) ;
2008-02-11 22:29:31 +03:00
}
* r - > out . account_name = account_name ;
2008-10-21 03:19:49 +04:00
if ( r - > out . authority_name ) {
* r - > out . authority_name = authority_name ;
}
2008-02-11 22:29:31 +03:00
return NT_STATUS_OK ;
2001-06-30 03:12:55 +04:00
}
2001-07-09 22:32:54 +04:00
/***************************************************************************
2008-02-06 20:58:11 +03:00
_lsa_CreateAccount
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-06 20:58:11 +03:00
NTSTATUS _lsa_CreateAccount ( pipes_struct * p ,
struct lsa_CreateAccount * r )
2001-07-09 22:32:54 +04:00
{
2009-07-16 20:45:29 +04:00
NTSTATUS status ;
2001-12-18 02:03:23 +03:00
struct lsa_info * handle ;
2001-07-09 22:32:54 +04:00
struct lsa_info * info ;
2009-07-16 20:45:29 +04:00
uint32_t acc_granted ;
struct security_descriptor * psd ;
2009-07-25 21:21:57 +04:00
size_t sd_size ;
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
/* find the connection policy handle. */
2008-02-06 20:58:11 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2005-01-13 21:20:37 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-07-18 17:31:36 +04:00
/* check if the user has enough rights */
2005-01-13 21:20:37 +03:00
2009-07-16 20:45:29 +04:00
if ( ! ( handle - > access & LSA_POLICY_CREATE_ACCOUNT ) ) {
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2009-07-16 20:45:29 +04:00
}
2009-10-20 17:54:40 +04:00
/* Work out max allowed. */
map_max_allowed_access ( p - > server_info - > ptok ,
& p - > server_info - > utok ,
& r - > in . access_mask ) ;
2009-07-16 20:45:29 +04:00
/* map the generic bits to the lsa policy ones */
se_map_generic ( & r - > in . access_mask , & lsa_account_mapping ) ;
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_account_mapping ,
r - > in . sid , LSA_POLICY_ALL_ACCESS ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2009-10-27 01:37:21 +03:00
status = access_check_object ( psd , p - > server_info - > ptok ,
NULL , 0 , r - > in . access_mask ,
& acc_granted , " _lsa_CreateAccount " ) ;
2009-07-16 20:45:29 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2008-02-14 15:12:28 +03:00
2008-02-06 20:58:11 +03:00
if ( is_privileged_sid ( r - > in . sid ) )
2005-01-18 21:29:28 +03:00
return NT_STATUS_OBJECT_NAME_COLLISION ;
2005-01-15 00:05:54 +03:00
2005-01-13 21:20:37 +03:00
/* associate the user/group SID with the (unique) handle. */
2008-02-14 15:12:28 +03:00
2009-01-07 20:44:52 +03:00
info = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_info ) ;
2009-01-07 20:11:24 +03:00
if ( info = = NULL ) {
2005-01-13 21:20:37 +03:00
return NT_STATUS_NO_MEMORY ;
2009-01-07 20:11:24 +03:00
}
2005-01-13 21:20:37 +03:00
2008-02-06 20:58:11 +03:00
info - > sid = * r - > in . sid ;
2009-07-16 20:45:29 +04:00
info - > access = acc_granted ;
2009-05-20 22:52:11 +04:00
info - > type = LSA_HANDLE_ACCOUNT_TYPE ;
2005-01-13 21:20:37 +03:00
/* get a (unique) handle. open a policy on it. */
2009-01-07 20:44:52 +03:00
if ( ! create_policy_hnd ( p , r - > out . acct_handle , info ) )
2005-01-13 21:20:37 +03:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
return privilege_create_account ( & info - > sid ) ;
}
/***************************************************************************
2008-02-06 21:19:29 +03:00
_lsa_OpenAccount
2005-01-13 21:20:37 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-06 21:19:29 +03:00
NTSTATUS _lsa_OpenAccount ( pipes_struct * p ,
struct lsa_OpenAccount * r )
2005-01-13 21:20:37 +03:00
{
struct lsa_info * handle ;
struct lsa_info * info ;
2010-05-18 12:29:34 +04:00
struct security_descriptor * psd = NULL ;
2009-05-20 22:52:11 +04:00
size_t sd_size ;
uint32_t des_access = r - > in . access_mask ;
uint32_t acc_granted ;
NTSTATUS status ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2008-02-06 21:19:29 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( handle - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2001-12-18 02:03:23 +03:00
2009-05-20 22:52:11 +04:00
/* des_access is for the account here, not the policy
* handle - so don ' t check against policy handle . */
/* Work out max allowed. */
2009-06-29 22:34:03 +04:00
map_max_allowed_access ( p - > server_info - > ptok ,
& p - > server_info - > utok ,
& des_access ) ;
2009-05-20 22:52:11 +04:00
/* map the generic bits to the lsa account ones */
se_map_generic ( & des_access , & lsa_account_mapping ) ;
/* get the generic lsa account SD until we store it */
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_account_mapping ,
r - > in . sid , LSA_ACCOUNT_ALL_ACCESS ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
status = access_check_object ( psd , p - > server_info - > ptok ,
2009-10-27 01:37:21 +03:00
NULL , 0 , des_access ,
& acc_granted , " _lsa_OpenAccount " ) ;
2009-05-20 22:52:11 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2001-12-18 02:03:23 +03:00
2005-01-13 21:20:37 +03:00
/* TODO: Fis the parsing routine before reenabling this check! */
#if 0
if ( ! lookup_sid ( & handle - > sid , dom_name , name , & type ) )
return NT_STATUS_ACCESS_DENIED ;
# endif
2001-07-09 22:32:54 +04:00
/* associate the user/group SID with the (unique) handle. */
2009-01-07 20:44:52 +03:00
info = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_info ) ;
2009-01-07 20:11:24 +03:00
if ( info = = NULL ) {
2001-07-09 22:32:54 +04:00
return NT_STATUS_NO_MEMORY ;
2009-01-07 20:11:24 +03:00
}
2001-07-09 22:32:54 +04:00
2008-02-06 21:19:29 +03:00
info - > sid = * r - > in . sid ;
2009-05-20 22:52:11 +04:00
info - > access = acc_granted ;
info - > type = LSA_HANDLE_ACCOUNT_TYPE ;
2001-07-09 22:32:54 +04:00
/* get a (unique) handle. open a policy on it. */
2009-01-07 20:44:52 +03:00
if ( ! create_policy_hnd ( p , r - > out . acct_handle , info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-14 03:53:00 +03:00
_lsa_EnumPrivsAccount
2001-11-23 18:11:22 +03:00
For a given SID , enumerate all the privilege this account has .
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 03:53:00 +03:00
NTSTATUS _lsa_EnumPrivsAccount ( pipes_struct * p ,
struct lsa_EnumPrivsAccount * r )
2001-07-09 22:32:54 +04:00
{
2008-02-14 03:53:00 +03:00
NTSTATUS status = NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
PRIVILEGE_SET privileges ;
2008-02-14 03:53:00 +03:00
struct lsa_PrivilegeSet * priv_set = NULL ;
struct lsa_LUIDAttribute * luid_attrs = NULL ;
int i ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2008-02-14 03:53:00 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_ACCOUNT_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_ACCOUNT_VIEW ) )
2008-10-18 02:24:15 +04:00
return NT_STATUS_ACCESS_DENIED ;
2009-06-17 00:17:24 +04:00
get_privileges_for_sids ( & mask , & info - > sid , 1 ) ;
2001-07-09 22:32:54 +04:00
2005-01-17 18:23:11 +03:00
privilege_set_init ( & privileges ) ;
2001-11-29 19:05:05 +03:00
2009-06-17 00:17:24 +04:00
priv_set = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_PrivilegeSet ) ;
if ( ! priv_set ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
2005-01-17 18:23:11 +03:00
if ( se_priv_to_privilege_set ( & privileges , & mask ) ) {
2001-07-09 22:32:54 +04:00
2008-02-14 03:53:00 +03:00
DEBUG ( 10 , ( " _lsa_EnumPrivsAccount: %s has %d privileges \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ,
privileges . count ) ) ;
2003-06-18 19:24:10 +04:00
2008-02-14 03:53:00 +03:00
luid_attrs = TALLOC_ZERO_ARRAY ( p - > mem_ctx ,
struct lsa_LUIDAttribute ,
privileges . count ) ;
if ( ! luid_attrs ) {
status = NT_STATUS_NO_MEMORY ;
goto done ;
}
for ( i = 0 ; i < privileges . count ; i + + ) {
luid_attrs [ i ] . luid . low = privileges . set [ i ] . luid . low ;
luid_attrs [ i ] . luid . high = privileges . set [ i ] . luid . high ;
luid_attrs [ i ] . attribute = privileges . set [ i ] . attr ;
}
priv_set - > count = privileges . count ;
priv_set - > unknown = 0 ;
priv_set - > set = luid_attrs ;
} else {
2009-06-17 00:17:24 +04:00
priv_set - > count = 0 ;
priv_set - > unknown = 0 ;
priv_set - > set = NULL ;
2005-01-17 18:23:11 +03:00
}
2001-07-09 22:32:54 +04:00
2009-06-17 00:17:24 +04:00
* r - > out . privs = priv_set ;
2008-02-14 03:53:00 +03:00
done :
2005-01-17 18:23:11 +03:00
privilege_set_free ( & privileges ) ;
2008-02-14 03:53:00 +03:00
return status ;
2001-07-09 22:32:54 +04:00
}
/***************************************************************************
2008-02-08 20:54:02 +03:00
_lsa_GetSystemAccessAccount
2001-07-09 22:32:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 20:54:02 +03:00
NTSTATUS _lsa_GetSystemAccessAccount ( pipes_struct * p ,
struct lsa_GetSystemAccessAccount * r )
2001-07-09 22:32:54 +04:00
{
2009-05-18 23:05:08 +04:00
NTSTATUS status ;
struct lsa_info * info = NULL ;
struct lsa_EnumPrivsAccount e ;
struct lsa_PrivilegeSet * privset ;
2001-07-09 22:32:54 +04:00
/* find the connection policy handle. */
2005-01-13 21:20:37 +03:00
2008-02-08 20:54:02 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-07-09 22:32:54 +04:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_ACCOUNT_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_ACCOUNT_VIEW ) )
2008-10-18 02:24:15 +04:00
return NT_STATUS_ACCESS_DENIED ;
2009-05-18 23:05:08 +04:00
privset = talloc_zero ( p - > mem_ctx , struct lsa_PrivilegeSet ) ;
if ( ! privset ) {
return NT_STATUS_NO_MEMORY ;
}
e . in . handle = r - > in . handle ;
e . out . privs = & privset ;
status = _lsa_EnumPrivsAccount ( p , & e ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 10 , ( " _lsa_GetSystemAccessAccount: "
" failed to call _lsa_EnumPrivsAccount(): %s \n " ,
nt_errstr ( status ) ) ) ;
return status ;
}
/* Samba4 would iterate over the privset to merge the policy mode bits,
* not sure samba3 can do the same here , so just return what we did in
* the past - gd */
2001-11-29 19:05:05 +03:00
/*
0x01 - > Log on locally
0x02 - > Access this computer from network
0x04 - > Log on as a batch job
0x10 - > Log on as a service
2008-02-14 15:12:28 +03:00
2001-11-29 19:05:05 +03:00
they can be ORed together
*/
2009-04-30 14:30:10 +04:00
* r - > out . access_mask = LSA_POLICY_MODE_INTERACTIVE |
LSA_POLICY_MODE_NETWORK ;
2001-07-09 22:32:54 +04:00
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-07-09 22:32:54 +04:00
}
2001-11-29 19:05:05 +03:00
/***************************************************************************
update the systemaccount information
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-08 20:32:05 +03:00
NTSTATUS _lsa_SetSystemAccessAccount ( pipes_struct * p ,
struct lsa_SetSystemAccessAccount * r )
2001-11-29 19:05:05 +03:00
{
struct lsa_info * info = NULL ;
GROUP_MAP map ;
/* find the connection policy handle. */
2008-02-08 20:32:05 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_ACCOUNT_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( ! ( info - > access & LSA_ACCOUNT_ADJUST_SYSTEM_ACCESS ) ) {
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2009-05-20 22:52:11 +04:00
}
2005-01-15 00:05:54 +03:00
2006-08-15 18:07:15 +04:00
if ( ! pdb_getgrsid ( & map , info - > sid ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_NO_SUCH_GROUP ;
2006-02-04 01:19:41 +03:00
return pdb_update_group_mapping_entry ( & map ) ;
2001-11-29 19:05:05 +03:00
}
/***************************************************************************
2008-02-14 15:50:32 +03:00
_lsa_AddPrivilegesToAccount
2001-11-29 19:05:05 +03:00
For a given SID , add some privileges .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:50:32 +03:00
NTSTATUS _lsa_AddPrivilegesToAccount ( pipes_struct * p ,
struct lsa_AddPrivilegesToAccount * r )
2001-11-29 19:05:05 +03:00
{
2003-10-06 05:38:46 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:50:32 +03:00
struct lsa_PrivilegeSet * set = NULL ;
2001-11-29 19:05:05 +03:00
/* find the connection policy handle. */
2008-02-14 15:50:32 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_ACCOUNT_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( ! ( info - > access & LSA_ACCOUNT_ADJUST_PRIVILEGES ) ) {
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-28 19:55:09 +03:00
}
2001-11-29 19:05:05 +03:00
2008-02-14 15:50:32 +03:00
set = r - > in . privs ;
2005-01-17 18:23:11 +03:00
if ( ! privilege_set_to_se_priv ( & mask , set ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-13 21:20:37 +03:00
2005-01-17 18:23:11 +03:00
if ( ! grant_privilege ( & info - > sid , & mask ) ) {
2008-02-14 15:50:32 +03:00
DEBUG ( 3 , ( " _lsa_AddPrivilegesToAccount: grant_privilege(%s) failed! \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ) ) ;
2005-01-17 18:23:11 +03:00
DEBUG ( 3 , ( " Privilege mask: \n " ) ) ;
dump_se_priv ( DBGC_ALL , 3 , & mask ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2001-11-29 19:05:05 +03:00
}
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-11-29 19:05:05 +03:00
}
/***************************************************************************
2008-02-14 15:50:32 +03:00
_lsa_RemovePrivilegesFromAccount
2001-11-29 19:05:05 +03:00
For a given SID , remove some privileges .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:50:32 +03:00
NTSTATUS _lsa_RemovePrivilegesFromAccount ( pipes_struct * p ,
struct lsa_RemovePrivilegesFromAccount * r )
2001-11-29 19:05:05 +03:00
{
2003-10-06 05:38:46 +04:00
struct lsa_info * info = NULL ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:50:32 +03:00
struct lsa_PrivilegeSet * set = NULL ;
2001-11-29 19:05:05 +03:00
/* find the connection policy handle. */
2008-02-14 15:50:32 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2001-11-29 19:05:05 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_ACCOUNT_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( ! ( info - > access & LSA_ACCOUNT_ADJUST_PRIVILEGES ) ) {
2005-01-15 00:05:54 +03:00
return NT_STATUS_ACCESS_DENIED ;
2005-01-28 19:55:09 +03:00
}
2005-01-15 00:05:54 +03:00
2008-02-14 15:50:32 +03:00
set = r - > in . privs ;
2001-11-29 19:05:05 +03:00
2005-01-17 18:23:11 +03:00
if ( ! privilege_set_to_se_priv ( & mask , set ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2005-01-13 21:20:37 +03:00
2005-01-17 18:23:11 +03:00
if ( ! revoke_privilege ( & info - > sid , & mask ) ) {
2008-02-14 15:50:32 +03:00
DEBUG ( 3 , ( " _lsa_RemovePrivilegesFromAccount: revoke_privilege(%s) failed! \n " ,
2007-12-15 23:11:36 +03:00
sid_string_dbg ( & info - > sid ) ) ) ;
2005-01-17 18:23:11 +03:00
DEBUG ( 3 , ( " Privilege mask: \n " ) ) ;
dump_se_priv ( DBGC_ALL , 3 , & mask ) ;
return NT_STATUS_NO_SUCH_PRIVILEGE ;
2001-11-29 19:05:05 +03:00
}
2005-01-13 21:20:37 +03:00
return NT_STATUS_OK ;
2001-11-29 19:05:05 +03:00
}
2009-07-16 20:32:53 +04:00
/***************************************************************************
_lsa_LookupPrivName
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS _lsa_LookupPrivName ( pipes_struct * p ,
struct lsa_LookupPrivName * r )
{
struct lsa_info * info = NULL ;
const char * name ;
struct lsa_StringLarge * lsa_name ;
/* find the connection policy handle. */
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_POLICY_VIEW_LOCAL_INFORMATION ) ) {
return NT_STATUS_ACCESS_DENIED ;
}
name = luid_to_privilege_name ( ( LUID * ) r - > in . luid ) ;
if ( ! name ) {
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
lsa_name = TALLOC_ZERO_P ( p - > mem_ctx , struct lsa_StringLarge ) ;
if ( ! lsa_name ) {
return NT_STATUS_NO_MEMORY ;
}
lsa_name - > string = talloc_strdup ( lsa_name , name ) ;
if ( ! lsa_name - > string ) {
TALLOC_FREE ( lsa_name ) ;
return NT_STATUS_NO_MEMORY ;
}
* r - > out . name = lsa_name ;
return NT_STATUS_OK ;
}
2001-12-14 20:31:48 +03:00
/***************************************************************************
2008-02-04 23:13:19 +03:00
_lsa_QuerySecurity
2001-12-14 20:31:48 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-04 23:13:19 +03:00
NTSTATUS _lsa_QuerySecurity ( pipes_struct * p ,
struct lsa_QuerySecurity * r )
2001-12-14 20:31:48 +03:00
{
2001-12-18 02:03:23 +03:00
struct lsa_info * handle = NULL ;
2010-05-18 12:29:34 +04:00
struct security_descriptor * psd = NULL ;
2001-12-14 20:31:48 +03:00
size_t sd_size ;
2001-12-18 02:03:23 +03:00
NTSTATUS status ;
2001-12-14 20:31:48 +03:00
/* find the connection policy handle. */
2008-02-04 23:13:19 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & handle ) )
2001-12-14 20:31:48 +03:00
return NT_STATUS_INVALID_HANDLE ;
2009-10-29 14:36:30 +03:00
switch ( handle - > type ) {
case LSA_HANDLE_POLICY_TYPE :
2009-05-20 22:52:11 +04:00
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_policy_mapping , NULL , 0 ) ;
2009-10-29 14:36:30 +03:00
break ;
case LSA_HANDLE_ACCOUNT_TYPE :
2009-05-20 22:52:11 +04:00
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_account_mapping ,
& handle - > sid , LSA_ACCOUNT_ALL_ACCESS ) ;
2009-10-29 14:36:30 +03:00
break ;
default :
2009-05-20 22:52:11 +04:00
status = NT_STATUS_INVALID_HANDLE ;
2009-10-29 14:36:30 +03:00
break ;
2009-05-20 22:52:11 +04:00
}
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2001-12-18 02:03:23 +03:00
2009-07-16 20:37:19 +04:00
* r - > out . sdbuf = make_sec_desc_buf ( p - > mem_ctx , sd_size , psd ) ;
if ( ! * r - > out . sdbuf ) {
return NT_STATUS_NO_MEMORY ;
2001-12-14 20:31:48 +03:00
}
2008-02-04 23:13:19 +03:00
return status ;
2001-12-14 20:31:48 +03:00
}
2005-01-15 05:20:30 +03:00
/***************************************************************************
2008-02-14 16:21:49 +03:00
_lsa_AddAccountRights
2005-01-15 05:20:30 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 16:21:49 +03:00
NTSTATUS _lsa_AddAccountRights ( pipes_struct * p ,
struct lsa_AddAccountRights * r )
2005-01-15 05:20:30 +03:00
{
struct lsa_info * info = NULL ;
int i = 0 ;
2009-05-20 22:52:11 +04:00
uint32_t acc_granted = 0 ;
2010-05-18 12:29:34 +04:00
struct security_descriptor * psd = NULL ;
2009-05-20 22:52:11 +04:00
size_t sd_size ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2009-05-20 22:52:11 +04:00
NTSTATUS status ;
2005-01-15 05:20:30 +03:00
/* find the connection policy handle. */
2008-02-14 16:21:49 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
2005-02-14 04:13:14 +03:00
}
2005-01-15 05:20:30 +03:00
2009-05-20 22:52:11 +04:00
/* get the generic lsa account SD for this SID until we store it */
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_account_mapping ,
r - > in . sid , LSA_ACCOUNT_ALL_ACCESS ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
/*
* From the MS DOCs . If the sid doesn ' t exist , ask for LSA_POLICY_CREATE_ACCOUNT
* on the policy handle . If it does , ask for
* LSA_ACCOUNT_ADJUST_PRIVILEGES | LSA_ACCOUNT_ADJUST_SYSTEM_ACCESS | LSA_ACCOUNT_VIEW ,
* on the account sid . We don ' t check here so just use the latter . JRA .
*/
2009-10-27 01:37:21 +03:00
status = access_check_object ( psd , p - > server_info - > ptok ,
NULL , 0 ,
LSA_ACCOUNT_ADJUST_PRIVILEGES | LSA_ACCOUNT_ADJUST_SYSTEM_ACCESS | LSA_ACCOUNT_VIEW ,
& acc_granted , " _lsa_AddAccountRights " ) ;
2009-05-20 22:52:11 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2005-01-15 05:20:30 +03:00
/* according to an NT4 PDC, you can add privileges to SIDs even without
call_lsa_create_account ( ) first . And you can use any arbitrary SID . */
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
for ( i = 0 ; i < r - > in . rights - > count ; i + + ) {
2008-02-14 15:12:28 +03:00
2008-02-14 16:21:49 +03:00
const char * privname = r - > in . rights - > names [ i ] . string ;
2005-03-26 09:52:56 +03:00
2005-01-15 05:20:30 +03:00
/* only try to add non-null strings */
2005-03-26 09:52:56 +03:00
2008-02-14 16:21:49 +03:00
if ( ! privname )
2005-03-26 09:52:56 +03:00
continue ;
if ( ! grant_privilege_by_name ( & sid , privname ) ) {
2008-02-14 16:21:49 +03:00
DEBUG ( 2 , ( " _lsa_AddAccountRights: Failed to add privilege [%s] \n " ,
privname ) ) ;
2005-01-15 05:20:30 +03:00
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
}
return NT_STATUS_OK ;
}
/***************************************************************************
2008-02-14 17:20:18 +03:00
_lsa_RemoveAccountRights
2005-01-15 05:20:30 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 17:20:18 +03:00
NTSTATUS _lsa_RemoveAccountRights ( pipes_struct * p ,
struct lsa_RemoveAccountRights * r )
2005-01-15 05:20:30 +03:00
{
struct lsa_info * info = NULL ;
int i = 0 ;
2010-05-18 12:29:34 +04:00
struct security_descriptor * psd = NULL ;
2009-05-20 22:52:11 +04:00
size_t sd_size ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 17:20:18 +03:00
const char * privname = NULL ;
2009-05-20 22:52:11 +04:00
uint32_t acc_granted = 0 ;
NTSTATUS status ;
2005-01-15 05:20:30 +03:00
/* find the connection policy handle. */
2008-02-14 17:20:18 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
2005-02-14 04:13:14 +03:00
}
2005-01-15 05:20:30 +03:00
2009-05-20 22:52:11 +04:00
/* get the generic lsa account SD for this SID until we store it */
status = make_lsa_object_sd ( p - > mem_ctx , & psd , & sd_size ,
& lsa_account_mapping ,
r - > in . sid , LSA_ACCOUNT_ALL_ACCESS ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
/*
* From the MS DOCs . We need
* LSA_ACCOUNT_ADJUST_PRIVILEGES | LSA_ACCOUNT_ADJUST_SYSTEM_ACCESS | LSA_ACCOUNT_VIEW
* and DELETE on the account sid .
*/
2009-10-27 01:37:21 +03:00
status = access_check_object ( psd , p - > server_info - > ptok ,
NULL , 0 ,
LSA_ACCOUNT_ADJUST_PRIVILEGES | LSA_ACCOUNT_ADJUST_SYSTEM_ACCESS |
LSA_ACCOUNT_VIEW | STD_RIGHT_DELETE_ACCESS ,
2009-10-27 01:47:01 +03:00
& acc_granted , " _lsa_RemoveAccountRights " ) ;
2009-05-20 22:52:11 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2008-02-14 17:20:18 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2005-01-15 05:20:30 +03:00
2008-02-14 17:20:18 +03:00
if ( r - > in . remove_all ) {
2008-02-14 15:12:28 +03:00
if ( ! revoke_all_privileges ( & sid ) )
2005-01-15 05:20:30 +03:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:12:28 +03:00
2005-01-15 05:20:30 +03:00
return NT_STATUS_OK ;
}
2008-02-14 15:12:28 +03:00
2008-02-14 17:20:18 +03:00
for ( i = 0 ; i < r - > in . rights - > count ; i + + ) {
2008-02-14 15:12:28 +03:00
2008-02-14 17:20:18 +03:00
privname = r - > in . rights - > names [ i ] . string ;
2005-03-26 09:52:56 +03:00
2005-01-15 05:20:30 +03:00
/* only try to add non-null strings */
2005-03-26 09:52:56 +03:00
2008-02-14 17:20:18 +03:00
if ( ! privname )
2005-03-26 09:52:56 +03:00
continue ;
if ( ! revoke_privilege_by_name ( & sid , privname ) ) {
2008-02-14 17:20:18 +03:00
DEBUG ( 2 , ( " _lsa_RemoveAccountRights: Failed to revoke privilege [%s] \n " ,
privname ) ) ;
2005-01-15 05:20:30 +03:00
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
}
return NT_STATUS_OK ;
}
2008-02-14 17:02:31 +03:00
/*******************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS init_lsa_right_set ( TALLOC_CTX * mem_ctx ,
struct lsa_RightSet * r ,
PRIVILEGE_SET * privileges )
{
uint32 i ;
const char * privname ;
const char * * privname_array = NULL ;
int num_priv = 0 ;
for ( i = 0 ; i < privileges - > count ; i + + ) {
privname = luid_to_privilege_name ( & privileges - > set [ i ] . luid ) ;
if ( privname ) {
if ( ! add_string_to_array ( mem_ctx , privname ,
& privname_array , & num_priv ) ) {
return NT_STATUS_NO_MEMORY ;
}
}
}
if ( num_priv ) {
r - > names = TALLOC_ZERO_ARRAY ( mem_ctx , struct lsa_StringLarge ,
num_priv ) ;
if ( ! r - > names ) {
return NT_STATUS_NO_MEMORY ;
}
for ( i = 0 ; i < num_priv ; i + + ) {
init_lsa_StringLarge ( & r - > names [ i ] , privname_array [ i ] ) ;
}
r - > count = num_priv ;
}
return NT_STATUS_OK ;
}
2005-01-15 05:20:30 +03:00
2005-03-26 09:52:56 +03:00
/***************************************************************************
2008-02-14 17:02:31 +03:00
_lsa_EnumAccountRights
2005-03-26 09:52:56 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 17:02:31 +03:00
NTSTATUS _lsa_EnumAccountRights ( pipes_struct * p ,
struct lsa_EnumAccountRights * r )
2005-01-15 06:54:03 +03:00
{
2008-02-14 17:02:31 +03:00
NTSTATUS status ;
2005-01-15 06:54:03 +03:00
struct lsa_info * info = NULL ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2005-01-15 06:54:03 +03:00
PRIVILEGE_SET privileges ;
2005-01-17 18:23:11 +03:00
SE_PRIV mask ;
2008-02-14 15:12:28 +03:00
2005-01-15 06:54:03 +03:00
/* find the connection policy handle. */
2008-02-14 15:12:28 +03:00
2008-02-14 17:02:31 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-01-15 06:54:03 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_ACCOUNT_VIEW ) ) {
2008-10-18 02:24:15 +04:00
return NT_STATUS_ACCESS_DENIED ;
2009-05-20 22:52:11 +04:00
}
2008-10-18 02:24:15 +04:00
2005-01-15 06:54:03 +03:00
/* according to an NT4 PDC, you can add privileges to SIDs even without
call_lsa_create_account ( ) first . And you can use any arbitrary SID . */
2008-02-14 15:12:28 +03:00
2008-02-14 17:02:31 +03:00
sid_copy ( & sid , r - > in . sid ) ;
2008-02-14 15:12:28 +03:00
2009-06-23 13:16:23 +04:00
/* according to MS-LSAD 3.1.4.5.10 it is required to return
* NT_STATUS_OBJECT_NAME_NOT_FOUND if the account sid was not found in
* the lsa database */
2005-01-17 18:23:11 +03:00
2009-06-23 13:16:23 +04:00
if ( ! get_privileges_for_sids ( & mask , & sid , 1 ) ) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
status = privilege_set_init ( & privileges ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
2005-01-15 06:54:03 +03:00
2009-06-17 00:17:24 +04:00
se_priv_to_privilege_set ( & privileges , & mask ) ;
2005-01-17 18:23:11 +03:00
2009-06-17 00:17:24 +04:00
DEBUG ( 10 , ( " _lsa_EnumAccountRights: %s has %d privileges \n " ,
sid_string_dbg ( & sid ) , privileges . count ) ) ;
2005-01-15 06:54:03 +03:00
2009-06-17 00:17:24 +04:00
status = init_lsa_right_set ( p - > mem_ctx , r - > out . rights , & privileges ) ;
2005-01-15 06:54:03 +03:00
privilege_set_free ( & privileges ) ;
2008-02-14 17:02:31 +03:00
return status ;
2005-01-15 06:54:03 +03:00
}
2005-03-26 09:52:56 +03:00
/***************************************************************************
2008-02-14 15:25:42 +03:00
_lsa_LookupPrivValue
2005-03-26 09:52:56 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-02-14 15:25:42 +03:00
NTSTATUS _lsa_LookupPrivValue ( pipes_struct * p ,
struct lsa_LookupPrivValue * r )
2005-03-10 21:50:47 +03:00
{
struct lsa_info * info = NULL ;
2008-02-14 15:25:42 +03:00
const char * name = NULL ;
2005-03-10 21:50:47 +03:00
LUID_ATTR priv_luid ;
SE_PRIV mask ;
2008-02-14 15:12:28 +03:00
2005-03-10 21:50:47 +03:00
/* find the connection policy handle. */
2008-02-14 15:12:28 +03:00
2008-02-14 15:25:42 +03:00
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) )
2005-03-10 21:50:47 +03:00
return NT_STATUS_INVALID_HANDLE ;
2008-02-14 15:12:28 +03:00
2009-05-20 22:52:11 +04:00
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_POLICY_LOOKUP_NAMES ) )
2008-10-18 02:24:15 +04:00
return NT_STATUS_ACCESS_DENIED ;
2008-02-14 15:25:42 +03:00
name = r - > in . name - > string ;
2008-02-14 15:12:28 +03:00
2005-06-29 20:35:32 +04:00
DEBUG ( 10 , ( " _lsa_lookup_priv_value: name = %s \n " , name ) ) ;
2005-03-10 21:50:47 +03:00
if ( ! se_priv_from_name ( name , & mask ) )
return NT_STATUS_NO_SUCH_PRIVILEGE ;
priv_luid = get_privilege_luid ( & mask ) ;
2008-02-14 15:25:42 +03:00
r - > out . luid - > low = priv_luid . luid . low ;
r - > out . luid - > high = priv_luid . luid . high ;
2005-03-10 21:50:47 +03:00
return NT_STATUS_OK ;
}
2006-10-10 12:39:11 +04:00
2009-07-16 04:25:43 +04:00
/***************************************************************************
_lsa_EnumAccountsWithUserRight
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS _lsa_EnumAccountsWithUserRight ( pipes_struct * p ,
struct lsa_EnumAccountsWithUserRight * r )
{
NTSTATUS status ;
struct lsa_info * info = NULL ;
struct dom_sid * sids = NULL ;
int num_sids = 0 ;
uint32_t i ;
SE_PRIV mask ;
if ( ! find_policy_by_hnd ( p , r - > in . handle , ( void * * ) ( void * ) & info ) ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( info - > type ! = LSA_HANDLE_POLICY_TYPE ) {
return NT_STATUS_INVALID_HANDLE ;
}
if ( ! ( info - > access & LSA_POLICY_LOOKUP_NAMES ) ) {
return NT_STATUS_ACCESS_DENIED ;
}
if ( ! r - > in . name | | ! r - > in . name - > string ) {
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
if ( ! se_priv_from_name ( r - > in . name - > string , & mask ) ) {
return NT_STATUS_NO_SUCH_PRIVILEGE ;
}
status = privilege_enum_sids ( & mask , p - > mem_ctx ,
& sids , & num_sids ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
r - > out . sids - > num_sids = num_sids ;
r - > out . sids - > sids = talloc_array ( p - > mem_ctx , struct lsa_SidPtr ,
r - > out . sids - > num_sids ) ;
for ( i = 0 ; i < r - > out . sids - > num_sids ; i + + ) {
r - > out . sids - > sids [ i ] . sid = sid_dup_talloc ( r - > out . sids - > sids ,
& sids [ i ] ) ;
if ( ! r - > out . sids - > sids [ i ] . sid ) {
TALLOC_FREE ( r - > out . sids - > sids ) ;
r - > out . sids - > num_sids = 0 ;
return NT_STATUS_NO_MEMORY ;
}
}
return NT_STATUS_OK ;
}
2009-07-16 03:05:25 +04:00
/***************************************************************************
_lsa_Delete
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS _lsa_Delete ( pipes_struct * p ,
struct lsa_Delete * r )
{
return NT_STATUS_NOT_SUPPORTED ;
}
2006-10-10 12:39:11 +04:00
/*
* From here on the server routines are just dummy ones to make smbd link with
* librpc / gen_ndr / srv_lsa . c . These routines are actually never called , we are
* pulling the server stubs across one by one .
2008-02-14 15:12:28 +03:00
*/
2006-10-10 12:39:11 +04:00
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetSecObj ( pipes_struct * p , struct lsa_SetSecObj * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_ChangePassword ( pipes_struct * p , struct lsa_ChangePassword * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInfoPolicy ( pipes_struct * p , struct lsa_SetInfoPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_ClearAuditLog ( pipes_struct * p , struct lsa_ClearAuditLog * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_GetQuotasForAccount ( pipes_struct * p , struct lsa_GetQuotasForAccount * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetQuotasForAccount ( pipes_struct * p , struct lsa_SetQuotasForAccount * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfo ( pipes_struct * p , struct lsa_QueryTrustedDomainInfo * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInformationTrustedDomain ( pipes_struct * p , struct lsa_SetInformationTrustedDomain * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QuerySecret ( pipes_struct * p , struct lsa_QuerySecret * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfoBySid ( pipes_struct * p , struct lsa_QueryTrustedDomainInfoBySid * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetTrustedDomainInfo ( pipes_struct * p , struct lsa_SetTrustedDomainInfo * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_DeleteTrustedDomain ( pipes_struct * p , struct lsa_DeleteTrustedDomain * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_StorePrivateData ( pipes_struct * p , struct lsa_StorePrivateData * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_RetrievePrivateData ( pipes_struct * p , struct lsa_RetrievePrivateData * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetInfoPolicy2 ( pipes_struct * p , struct lsa_SetInfoPolicy2 * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryTrustedDomainInfoByName ( pipes_struct * p , struct lsa_QueryTrustedDomainInfoByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetTrustedDomainInfoByName ( pipes_struct * p , struct lsa_SetTrustedDomainInfoByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_EnumTrustedDomainsEx ( pipes_struct * p , struct lsa_EnumTrustedDomainsEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomainEx ( pipes_struct * p , struct lsa_CreateTrustedDomainEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CloseTrustedDomainEx ( pipes_struct * p , struct lsa_CloseTrustedDomainEx * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_QueryDomainInformationPolicy ( pipes_struct * p , struct lsa_QueryDomainInformationPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_SetDomainInformationPolicy ( pipes_struct * p , struct lsa_SetDomainInformationPolicy * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_OpenTrustedDomainByName ( pipes_struct * p , struct lsa_OpenTrustedDomainByName * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_TestCall ( pipes_struct * p , struct lsa_TestCall * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CreateTrustedDomainEx2 ( pipes_struct * p , struct lsa_CreateTrustedDomainEx2 * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRWRITE ( pipes_struct * p , struct lsa_CREDRWRITE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRREAD ( pipes_struct * p , struct lsa_CREDRREAD * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRENUMERATE ( pipes_struct * p , struct lsa_CREDRENUMERATE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS ( pipes_struct * p , struct lsa_CREDRWRITEDOMAINCREDENTIALS * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS ( pipes_struct * p , struct lsa_CREDRREADDOMAINCREDENTIALS * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRDELETE ( pipes_struct * p , struct lsa_CREDRDELETE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRGETTARGETINFO ( pipes_struct * p , struct lsa_CREDRGETTARGETINFO * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRPROFILELOADED ( pipes_struct * p , struct lsa_CREDRPROFILELOADED * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRGETSESSIONTYPES ( pipes_struct * p , struct lsa_CREDRGETSESSIONTYPES * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARREGISTERAUDITEVENT ( pipes_struct * p , struct lsa_LSARREGISTERAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARGENAUDITEVENT ( pipes_struct * p , struct lsa_LSARGENAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT ( pipes_struct * p , struct lsa_LSARUNREGISTERAUDITEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2008-01-16 18:31:49 +03:00
NTSTATUS _lsa_lsaRQueryForestTrustInformation ( pipes_struct * p , struct lsa_lsaRQueryForestTrustInformation * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2010-03-16 16:03:35 +03:00
NTSTATUS _lsa_lsaRSetForestTrustInformation ( pipes_struct * p , struct lsa_lsaRSetForestTrustInformation * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_CREDRRENAME ( pipes_struct * p , struct lsa_CREDRRENAME * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSAROPENPOLICYSCE ( pipes_struct * p , struct lsa_LSAROPENPOLICYSCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE ( pipes_struct * p , struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE ( pipes_struct * p , struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}
2007-01-18 13:18:59 +03:00
NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT ( pipes_struct * p , struct lsa_LSARADTREPORTSECURITYEVENT * r )
2006-10-10 12:39:11 +04:00
{
p - > rng_fault_state = True ;
return NT_STATUS_NOT_IMPLEMENTED ;
}