2003-01-15 19:10:57 +03:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-01-12 01:49:30 +03:00
RPC pipe client
2002-07-15 14:35:28 +04:00
Copyright ( C ) Tim Potter 2000
Copyright ( C ) Rafal Szczesniak 2002
2008-02-27 21:38:48 +03:00
Copyright ( C ) Guenther Deschner 2008
2001-01-12 01:49:30 +03:00
1998-09-26 01:01:52 +04: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
1998-09-26 01:01:52 +04:00
( at your option ) any later version .
2010-01-23 15:33:10 +03:00
1998-09-26 01:01:52 +04: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 .
2010-01-23 15:33:10 +03:00
1998-09-26 01:01:52 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1998-09-26 01:01:52 +04:00
*/
# include "includes.h"
2001-10-12 09:56:23 +04:00
# include "rpcclient.h"
2009-03-16 13:27:58 +03:00
# include "../libcli/auth/libcli_auth.h"
2010-08-06 16:52:58 +04:00
# include "../librpc/gen_ndr/ndr_lsa.h"
2011-01-18 18:08:05 +03:00
# include "../librpc/gen_ndr/ndr_lsa_c.h"
2010-05-18 20:26:16 +04:00
# include "rpc_client/cli_lsarpc.h"
2010-08-20 01:15:22 +04:00
# include "rpc_client/init_lsa.h"
2010-10-12 08:27:50 +04:00
# include "../libcli/security/security.h"
2000-12-08 06:34:00 +03:00
2003-01-29 00:09:56 +03:00
/* useful function to allow entering a name instead of a SID and
* looking it up automatically */
2005-09-30 21:13:37 +04:00
static NTSTATUS name_to_sid ( struct rpc_pipe_client * cli ,
2003-01-29 05:24:12 +03:00
TALLOC_CTX * mem_ctx ,
2010-05-21 05:25:01 +04:00
struct dom_sid * sid , const char * name )
2003-01-29 00:09:56 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType * sid_types ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sids ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2003-01-29 00:09:56 +03:00
/* maybe its a raw SID */
if ( strncmp ( name , " S- " , 2 ) = = 0 & &
2003-01-29 05:24:12 +03:00
string_to_sid ( sid , name ) ) {
2003-01-29 00:09:56 +03:00
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2003-01-29 05:24:12 +03:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 00:09:56 +03:00
goto done ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_lookup_names ( cli , mem_ctx , & pol , 1 , & name , NULL , 1 , & sids , & sid_types ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 00:09:56 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2003-01-29 00:09:56 +03:00
* sid = sids [ 0 ] ;
done :
2011-01-18 17:42:47 +03:00
return status ;
2003-01-29 00:09:56 +03:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_1 ( struct lsa_AuditLogInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " percent_full: \t %d \n " , r - > percent_full ) ;
2008-10-21 00:06:58 +04:00
d_printf ( " maximum_log_size: \t %d \n " , r - > maximum_log_size ) ;
2008-02-08 03:38:44 +03:00
d_printf ( " retention_time: \t %lld \n " , ( long long ) r - > retention_time ) ;
d_printf ( " shutdown_in_progress: \t %d \n " , r - > shutdown_in_progress ) ;
d_printf ( " time_to_shutdown: \t %lld \n " , ( long long ) r - > time_to_shutdown ) ;
d_printf ( " next_audit_record: \t %d \n " , r - > next_audit_record ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_2 ( struct lsa_AuditEventsInfo * r )
2006-04-11 19:47:24 +04:00
{
int i ;
2008-02-08 03:38:44 +03:00
d_printf ( " Auditing enabled: \t %d \n " , r - > auditing_mode ) ;
d_printf ( " Auditing categories: \t %d \n " , r - > count ) ;
2006-04-11 19:47:24 +04:00
d_printf ( " Auditsettings: \n " ) ;
2008-02-08 03:38:44 +03:00
for ( i = 0 ; i < r - > count ; i + + ) {
const char * val = audit_policy_str ( talloc_tos ( ) , r - > settings [ i ] ) ;
2006-04-11 19:47:24 +04:00
const char * policy = audit_description_str ( i ) ;
d_printf ( " %s: \t %s \n " , policy , val ) ;
}
}
2008-02-08 03:38:44 +03:00
static void display_query_info_3 ( struct lsa_DomainInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " Domain Name: %s \n " , r - > name . string ) ;
d_printf ( " Domain Sid: %s \n " , sid_string_tos ( r - > sid ) ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_5 ( struct lsa_DomainInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " Domain Name: %s \n " , r - > name . string ) ;
d_printf ( " Domain Sid: %s \n " , sid_string_tos ( r - > sid ) ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_10 ( struct lsa_AuditFullSetInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " Shutdown on full: %d \n " , r - > shutdown_on_full ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_11 ( struct lsa_AuditFullQueryInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " Shutdown on full: %d \n " , r - > shutdown_on_full ) ;
d_printf ( " Log is full: %d \n " , r - > log_is_full ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_query_info_12 ( struct lsa_DnsDomainInfo * r )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
d_printf ( " Domain NetBios Name: %s \n " , r - > name . string ) ;
d_printf ( " Domain DNS Name: %s \n " , r - > dns_domain . string ) ;
d_printf ( " Domain Forest Name: %s \n " , r - > dns_forest . string ) ;
d_printf ( " Domain Sid: %s \n " , sid_string_tos ( r - > sid ) ) ;
2008-10-14 04:26:18 +04:00
d_printf ( " Domain GUID: %s \n " , GUID_string ( talloc_tos ( ) ,
& r - > domain_guid ) ) ;
2006-04-11 19:47:24 +04:00
}
2008-02-08 03:38:44 +03:00
static void display_lsa_query_info ( union lsa_PolicyInformation * info ,
enum lsa_PolicyInfo level )
2006-04-11 19:47:24 +04:00
{
2008-02-08 03:38:44 +03:00
switch ( level ) {
2006-04-11 19:47:24 +04:00
case 1 :
2008-02-08 03:38:44 +03:00
display_query_info_1 ( & info - > audit_log ) ;
2006-04-11 19:47:24 +04:00
break ;
case 2 :
2008-02-08 03:38:44 +03:00
display_query_info_2 ( & info - > audit_events ) ;
2006-04-11 19:47:24 +04:00
break ;
case 3 :
2008-02-08 03:38:44 +03:00
display_query_info_3 ( & info - > domain ) ;
2006-04-11 19:47:24 +04:00
break ;
case 5 :
2008-02-08 03:38:44 +03:00
display_query_info_5 ( & info - > account_domain ) ;
2006-04-11 19:47:24 +04:00
break ;
case 10 :
2008-02-08 03:38:44 +03:00
display_query_info_10 ( & info - > auditfullset ) ;
2006-04-11 19:47:24 +04:00
break ;
case 11 :
2008-02-08 03:38:44 +03:00
display_query_info_11 ( & info - > auditfullquery ) ;
2006-04-11 19:47:24 +04:00
break ;
case 12 :
2008-02-08 03:38:44 +03:00
display_query_info_12 ( & info - > dns ) ;
2006-04-11 19:47:24 +04:00
break ;
default :
2008-02-08 03:38:44 +03:00
printf ( " can't display info level: %d \n " , level ) ;
2006-04-11 19:47:24 +04:00
break ;
}
}
2001-10-12 09:56:23 +04:00
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_query_info_policy ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-01-12 01:49:30 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-08 03:38:44 +03:00
union lsa_PolicyInformation * info = NULL ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2004-01-08 11:19:18 +03:00
2015-05-09 17:33:08 +03:00
uint32_t info_class = 3 ;
2001-01-12 01:49:30 +03:00
if ( argc > 2 ) {
printf ( " Usage: %s [info_class] \n " , argv [ 0 ] ) ;
2001-09-04 11:13:01 +04:00
return NT_STATUS_OK ;
2000-12-08 06:34:00 +03:00
}
1999-11-02 01:25:38 +03:00
2001-10-12 09:56:23 +04:00
if ( argc = = 2 )
2001-01-12 01:49:30 +03:00
info_class = atoi ( argv [ 1 ] ) ;
2006-04-11 19:47:24 +04:00
2002-08-17 19:33:49 +04:00
switch ( info_class ) {
case 12 :
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2006-04-11 19:47:24 +04:00
& pol ) ;
2002-08-17 19:33:49 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2002-08-17 19:33:49 +04:00
goto done ;
2010-01-23 15:33:10 +03:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QueryInfoPolicy2 ( b , mem_ctx ,
2008-02-08 03:38:44 +03:00
& pol ,
info_class ,
2011-01-18 18:08:05 +03:00
& info ,
& result ) ;
2002-08-17 19:33:49 +04:00
break ;
default :
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2006-04-11 19:47:24 +04:00
& pol ) ;
1998-09-26 01:01:52 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2002-08-17 19:33:49 +04:00
goto done ;
2010-01-23 15:33:10 +03:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QueryInfoPolicy ( b , mem_ctx ,
2008-02-08 03:38:44 +03:00
& pol ,
info_class ,
2011-01-18 18:08:05 +03:00
& info ,
& result ) ;
2002-08-17 19:33:49 +04:00
}
2001-10-12 09:56:23 +04:00
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
status = result ;
if ( NT_STATUS_IS_OK ( result ) ) {
2008-02-11 12:28:36 +03:00
display_lsa_query_info ( info , info_class ) ;
}
2005-09-30 21:13:37 +04:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-09-30 21:13:37 +04:00
2001-10-12 09:56:23 +04:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-01-12 01:49:30 +03:00
}
1998-09-26 01:01:52 +04:00
2001-01-12 01:49:30 +03:00
/* Resolve a list of names to a list of sids */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_lookup_names ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-01-12 01:49:30 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sids ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType * types ;
2002-04-15 09:02:22 +04:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
1998-09-26 01:01:52 +04:00
2001-01-12 01:49:30 +03:00
if ( argc = = 1 ) {
printf ( " Usage: %s [name1 [name2 [...]]] \n " , argv [ 0 ] ) ;
2001-09-04 11:13:01 +04:00
return NT_STATUS_OK ;
2000-12-08 06:34:00 +03:00
}
1998-09-26 01:01:52 +04:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-09-04 11:13:01 +04:00
& pol ) ;
1998-09-26 01:01:52 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-10-12 09:56:23 +04:00
goto done ;
1998-09-26 01:01:52 +04:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_lookup_names ( cli , mem_ctx , & pol , argc - 1 ,
2007-06-27 15:42:17 +04:00
( const char * * ) ( argv + 1 ) , NULL , 1 , & sids , & types ) ;
2001-10-12 09:56:23 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) & & NT_STATUS_V ( status ) ! =
2002-07-15 14:35:28 +04:00
NT_STATUS_V ( STATUS_SOME_UNMAPPED ) )
2001-01-12 01:49:30 +03:00
goto done ;
2000-12-08 06:34:00 +03:00
2011-01-18 17:42:47 +03:00
status = NT_STATUS_OK ;
2002-07-15 14:35:28 +04:00
2001-01-12 01:49:30 +03:00
/* Print results */
2000-12-08 06:34:00 +03:00
2002-04-15 09:02:22 +04:00
for ( i = 0 ; i < ( argc - 1 ) ; i + + ) {
2001-01-12 01:49:30 +03:00
fstring sid_str ;
2007-12-16 00:47:30 +03:00
sid_to_fstring ( sid_str , & sids [ i ] ) ;
2002-07-15 14:35:28 +04:00
printf ( " %s %s (%s: %d) \n " , argv [ i + 1 ] , sid_str ,
sid_type_lookup ( types [ i ] ) , types [ i ] ) ;
1998-09-26 01:01:52 +04:00
}
2000-12-08 06:34:00 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-03-10 21:50:47 +03:00
2001-01-12 01:49:30 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
1998-09-30 23:09:57 +04:00
}
2007-06-27 16:27:00 +04:00
/* Resolve a list of names to a list of sids */
static NTSTATUS cmd_lsa_lookup_names_level ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sids ;
2007-06-27 16:27:00 +04:00
enum lsa_SidType * types ;
int i , level ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2007-06-27 16:27:00 +04:00
if ( argc < 3 ) {
printf ( " Usage: %s [level] [name1 [name2 [...]]] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2007-06-27 16:27:00 +04:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2007-06-27 16:27:00 +04:00
goto done ;
level = atoi ( argv [ 1 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_lookup_names ( cli , mem_ctx , & pol , argc - 2 ,
2007-06-27 16:27:00 +04:00
( const char * * ) ( argv + 2 ) , NULL , level , & sids , & types ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) & & NT_STATUS_V ( status ) ! =
2007-06-27 16:27:00 +04:00
NT_STATUS_V ( STATUS_SOME_UNMAPPED ) )
goto done ;
2011-01-18 17:42:47 +03:00
status = NT_STATUS_OK ;
2007-06-27 16:27:00 +04:00
/* Print results */
for ( i = 0 ; i < ( argc - 2 ) ; i + + ) {
fstring sid_str ;
2007-12-16 00:47:30 +03:00
sid_to_fstring ( sid_str , & sids [ i ] ) ;
2007-06-27 16:27:00 +04:00
printf ( " %s %s (%s: %d) \n " , argv [ i + 2 ] , sid_str ,
sid_type_lookup ( types [ i ] ) , types [ i ] ) ;
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2007-06-27 16:27:00 +04:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2007-06-27 16:27:00 +04:00
}
2009-09-11 01:33:37 +04:00
static NTSTATUS cmd_lsa_lookup_names4 ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-09-11 01:33:37 +04:00
uint32_t num_names ;
struct lsa_String * names ;
2013-11-08 09:40:55 +04:00
struct lsa_RefDomainList * domains = NULL ;
2009-09-11 01:33:37 +04:00
struct lsa_TransSidArray3 sids ;
uint32_t count = 0 ;
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-09-11 01:33:37 +04:00
if ( argc = = 1 ) {
printf ( " Usage: %s [name1 [name2 [...]]] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
ZERO_STRUCT ( sids ) ;
num_names = argc - 1 ;
names = talloc_array ( mem_ctx , struct lsa_String , num_names ) ;
NT_STATUS_HAVE_NO_MEMORY ( names ) ;
for ( i = 0 ; i < num_names ; i + + ) {
init_lsa_String ( & names [ i ] , argv [ i + 1 ] ) ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupNames4 ( b , mem_ctx ,
2009-09-11 01:33:37 +04:00
num_names ,
names ,
& domains ,
& sids ,
1 ,
& count ,
0 ,
2011-01-18 18:08:05 +03:00
0 ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
2009-09-11 01:33:37 +04:00
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
return result ;
}
2009-09-11 01:33:37 +04:00
2013-11-08 09:40:55 +04:00
if ( sids . count ! = num_names ) {
return NT_STATUS_INVALID_NETWORK_RESPONSE ;
}
2009-09-11 01:33:37 +04:00
for ( i = 0 ; i < sids . count ; i + + ) {
fstring sid_str ;
sid_to_fstring ( sid_str , sids . sids [ i ] . sid ) ;
printf ( " %s %s (%s: %d) \n " , argv [ i + 1 ] , sid_str ,
sid_type_lookup ( sids . sids [ i ] . sid_type ) ,
sids . sids [ i ] . sid_type ) ;
}
2011-01-18 17:42:47 +03:00
return status ;
2009-09-11 01:33:37 +04:00
}
2007-06-27 16:27:00 +04:00
2001-01-12 01:49:30 +03:00
/* Resolve a list of SIDs to a list of names */
2000-12-08 06:34:00 +03:00
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_lookup_sids ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
1998-11-25 22:57:04 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid * sids ;
2002-01-20 04:24:59 +03:00
char * * domains ;
2000-12-08 06:34:00 +03:00
char * * names ;
2006-09-08 18:28:06 +04:00
enum lsa_SidType * types ;
2002-04-15 09:02:22 +04:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
1998-09-30 23:09:57 +04:00
2000-12-08 06:34:00 +03:00
if ( argc = = 1 ) {
2001-01-12 01:49:30 +03:00
printf ( " Usage: %s [sid1 [sid2 [...]]] \n " , argv [ 0 ] ) ;
2001-09-04 11:13:01 +04:00
return NT_STATUS_OK ;
2000-12-08 06:34:00 +03:00
}
1998-09-30 23:09:57 +04:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-09-04 11:13:01 +04:00
& pol ) ;
1998-11-11 17:23:55 +03:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-10-12 09:56:23 +04:00
goto done ;
1998-09-30 23:09:57 +04:00
2001-01-12 01:49:30 +03:00
/* Convert arguments to sids */
1999-12-13 16:27:58 +03:00
2011-06-07 05:30:12 +04:00
sids = talloc_array ( mem_ctx , struct dom_sid , argc - 1 ) ;
1998-09-30 23:09:57 +04:00
2001-01-12 01:49:30 +03:00
if ( ! sids ) {
2001-10-12 09:56:23 +04:00
printf ( " could not allocate memory for %d sids \n " , argc - 1 ) ;
2001-01-12 01:49:30 +03:00
goto done ;
2000-12-08 06:34:00 +03:00
}
1998-09-30 23:09:57 +04:00
2005-02-28 14:11:55 +03:00
for ( i = 0 ; i < argc - 1 ; i + + )
if ( ! string_to_sid ( & sids [ i ] , argv [ i + 1 ] ) ) {
2011-01-18 17:42:47 +03:00
status = NT_STATUS_INVALID_SID ;
2003-02-18 10:05:02 +03:00
goto done ;
}
1999-12-13 16:27:58 +03:00
2001-01-12 01:49:30 +03:00
/* Lookup the SIDs */
1998-09-30 23:09:57 +04:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_lookup_sids ( cli , mem_ctx , & pol , argc - 1 , sids ,
2002-04-15 09:02:22 +04:00
& domains , & names , & types ) ;
2001-10-12 09:56:23 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) & & NT_STATUS_V ( status ) ! =
2002-07-15 14:35:28 +04:00
NT_STATUS_V ( STATUS_SOME_UNMAPPED ) )
2001-01-12 01:49:30 +03:00
goto done ;
2000-12-08 06:34:00 +03:00
2011-01-18 17:42:47 +03:00
status = NT_STATUS_OK ;
2002-07-15 14:35:28 +04:00
2001-01-12 01:49:30 +03:00
/* Print results */
2005-03-10 21:50:47 +03:00
for ( i = 0 ; i < ( argc - 1 ) ; i + + ) {
2001-01-12 01:49:30 +03:00
fstring sid_str ;
2000-12-08 06:34:00 +03:00
2007-12-16 00:47:30 +03:00
sid_to_fstring ( sid_str , & sids [ i ] ) ;
2013-09-18 11:32:17 +04:00
if ( types [ i ] = = SID_NAME_DOMAIN ) {
printf ( " %s %s (%d) \n " , sid_str ,
domains [ i ] ? domains [ i ] : " *unknown* " ,
types [ i ] ) ;
} else {
printf ( " %s %s \\ %s (%d) \n " , sid_str ,
domains [ i ] ? domains [ i ] : " *unknown* " ,
names [ i ] ? names [ i ] : " *unknown* " ,
types [ i ] ) ;
}
1998-09-26 01:01:52 +04:00
}
2000-12-08 06:34:00 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-03-10 21:50:47 +03:00
2001-01-12 01:49:30 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
1999-03-18 08:16:59 +03:00
}
2009-09-11 15:58:52 +04:00
/* Resolve a list of SIDs to a list of names */
static NTSTATUS cmd_lsa_lookup_sids3 ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx ,
int argc , const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status = NT_STATUS_UNSUCCESSFUL , result ;
2009-09-11 15:58:52 +04:00
int i ;
struct lsa_SidArray sids ;
2013-11-08 08:38:01 +04:00
struct lsa_RefDomainList * domains = NULL ;
2009-09-11 15:58:52 +04:00
struct lsa_TransNameArray2 names ;
uint32_t count = 0 ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-09-11 15:58:52 +04:00
if ( argc = = 1 ) {
printf ( " Usage: %s [sid1 [sid2 [...]]] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
ZERO_STRUCT ( names ) ;
/* Convert arguments to sids */
sids . num_sids = argc - 1 ;
sids . sids = talloc_array ( mem_ctx , struct lsa_SidPtr , sids . num_sids ) ;
if ( ! sids . sids ) {
printf ( " could not allocate memory for %d sids \n " , sids . num_sids ) ;
goto done ;
}
for ( i = 0 ; i < sids . num_sids ; i + + ) {
2010-01-23 15:30:04 +03:00
sids . sids [ i ] . sid = talloc ( sids . sids , struct dom_sid ) ;
if ( sids . sids [ i ] . sid = = NULL ) {
2011-01-18 17:42:47 +03:00
status = NT_STATUS_NO_MEMORY ;
2010-01-23 15:30:04 +03:00
goto done ;
}
if ( ! string_to_sid ( sids . sids [ i ] . sid , argv [ i + 1 ] ) ) {
2011-01-18 17:42:47 +03:00
status = NT_STATUS_INVALID_SID ;
2009-09-11 15:58:52 +04:00
goto done ;
}
}
/* Lookup the SIDs */
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupSids3 ( b , mem_ctx ,
2009-09-11 15:58:52 +04:00
& sids ,
& domains ,
& names ,
1 ,
& count ,
0 ,
2011-01-18 18:08:05 +03:00
0 ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2009-09-11 15:58:52 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
}
if ( ! NT_STATUS_IS_OK ( result ) & & NT_STATUS_V ( result ) ! =
NT_STATUS_V ( STATUS_SOME_UNMAPPED ) ) {
status = result ;
goto done ;
}
2009-09-11 15:58:52 +04:00
2011-01-18 17:42:47 +03:00
status = NT_STATUS_OK ;
2009-09-11 15:58:52 +04:00
/* Print results */
2013-11-08 08:38:01 +04:00
for ( i = 0 ; i < names . count ; i + + ) {
2009-09-11 15:58:52 +04:00
fstring sid_str ;
2013-11-08 08:38:01 +04:00
if ( i > = sids . num_sids ) {
break ;
}
2009-09-11 15:58:52 +04:00
sid_to_fstring ( sid_str , sids . sids [ i ] . sid ) ;
printf ( " %s %s (%d) \n " , sid_str ,
names . names [ i ] . name . string ,
names . names [ i ] . sid_type ) ;
}
done :
2011-01-18 17:42:47 +03:00
return status ;
2009-09-11 15:58:52 +04:00
}
2001-01-12 01:49:30 +03:00
/* Enumerate list of trusted domains */
2000-12-08 06:34:00 +03:00
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_enum_trust_dom ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-01-12 01:49:30 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-13 02:25:40 +03:00
struct lsa_DomainList domain_list ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2002-07-15 14:35:28 +04:00
/* defaults, but may be changed using params */
2015-05-09 17:33:08 +03:00
uint32_t enum_ctx = 0 ;
2001-03-23 23:41:22 +03:00
int i ;
2008-02-13 02:25:40 +03:00
uint32_t max_size = ( uint32_t ) - 1 ;
2001-01-12 01:49:30 +03:00
2002-08-17 19:33:49 +04:00
if ( argc > 2 ) {
printf ( " Usage: %s [enum context (0)] \n " , argv [ 0 ] ) ;
2001-09-04 11:13:01 +04:00
return NT_STATUS_OK ;
2001-01-12 01:49:30 +03:00
}
2000-12-08 06:34:00 +03:00
2002-08-17 19:33:49 +04:00
if ( argc = = 2 & & argv [ 1 ] ) {
2002-07-15 14:35:28 +04:00
enum_ctx = atoi ( argv [ 2 ] ) ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2008-02-27 17:49:31 +03:00
LSA_POLICY_VIEW_LOCAL_INFORMATION ,
2001-09-04 11:13:01 +04:00
& pol ) ;
2000-12-08 06:34:00 +03:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-10-12 09:56:23 +04:00
goto done ;
2001-01-12 01:49:30 +03:00
2011-01-18 17:42:47 +03:00
status = STATUS_MORE_ENTRIES ;
2005-01-22 20:12:19 +03:00
2011-01-18 17:42:47 +03:00
while ( NT_STATUS_EQUAL ( status , STATUS_MORE_ENTRIES ) ) {
2001-01-12 01:49:30 +03:00
2005-01-22 20:12:19 +03:00
/* Lookup list of trusted domains */
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumTrustDom ( b , mem_ctx ,
2008-02-13 02:25:40 +03:00
& pol ,
& enum_ctx ,
& domain_list ,
2011-01-18 18:08:05 +03:00
max_size ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( ! NT_STATUS_IS_OK ( result ) & &
! NT_STATUS_EQUAL ( result , NT_STATUS_NO_MORE_ENTRIES ) & &
! NT_STATUS_EQUAL ( result , STATUS_MORE_ENTRIES ) ) {
status = result ;
2005-01-22 20:12:19 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
}
2005-01-22 20:12:19 +03:00
/* Print results: list of names and sids returned in this
* response . */
2008-02-13 02:25:40 +03:00
for ( i = 0 ; i < domain_list . count ; i + + ) {
2005-01-22 20:12:19 +03:00
fstring sid_str ;
2008-02-13 02:25:40 +03:00
sid_to_fstring ( sid_str , domain_list . domains [ i ] . sid ) ;
printf ( " %s %s \n " ,
domain_list . domains [ i ] . name . string ?
domain_list . domains [ i ] . name . string : " *unknown* " ,
sid_str ) ;
2005-01-22 20:12:19 +03:00
}
2001-01-12 01:49:30 +03:00
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-01-12 01:49:30 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2000-12-08 06:34:00 +03:00
}
2001-01-12 01:49:30 +03:00
2001-11-22 19:12:43 +03:00
/* Enumerates privileges */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_enum_privilege ( struct rpc_pipe_client * cli ,
2003-02-26 02:51:56 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2001-11-22 19:12:43 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-11 12:33:31 +03:00
struct lsa_PrivArray priv_array ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-11-22 19:12:43 +03:00
2015-05-09 17:33:08 +03:00
uint32_t enum_context = 0 ;
uint32_t pref_max_length = 0x1000 ;
2001-11-22 19:12:43 +03:00
int i ;
2001-11-23 02:50:16 +03:00
if ( argc > 3 ) {
printf ( " Usage: %s [enum context] [max length] \n " , argv [ 0 ] ) ;
2001-11-22 19:12:43 +03:00
return NT_STATUS_OK ;
}
2001-11-23 02:50:16 +03:00
if ( argc > = 2 )
enum_context = atoi ( argv [ 1 ] ) ;
if ( argc = = 3 )
pref_max_length = atoi ( argv [ 2 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-11-22 19:12:43 +03:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-22 19:12:43 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumPrivs ( b , mem_ctx ,
2008-02-11 12:33:31 +03:00
& pol ,
& enum_context ,
& priv_array ,
2011-01-18 18:08:05 +03:00
pref_max_length ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-22 19:12:43 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-22 19:12:43 +03:00
/* Print results */
2008-02-11 12:33:31 +03:00
printf ( " found %d privileges \n \n " , priv_array . count ) ;
for ( i = 0 ; i < priv_array . count ; i + + ) {
printf ( " %s \t \t %d:%d (0x%x:0x%x) \n " ,
priv_array . privs [ i ] . name . string ? priv_array . privs [ i ] . name . string : " *unknown* " ,
priv_array . privs [ i ] . luid . high ,
priv_array . privs [ i ] . luid . low ,
priv_array . privs [ i ] . luid . high ,
priv_array . privs [ i ] . luid . low ) ;
2001-11-22 19:12:43 +03:00
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-11-22 19:12:43 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-11-22 19:12:43 +03:00
}
2001-11-22 19:54:48 +03:00
/* Get privilege name */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_get_dispname ( struct rpc_pipe_client * cli ,
2001-11-22 19:54:48 +03:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-11-22 19:54:48 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-11-22 19:54:48 +03:00
2015-05-09 17:33:08 +03:00
uint16_t lang_id = 0 ;
uint16_t lang_id_sys = 0 ;
uint16_t lang_id_desc ;
2008-02-11 14:17:27 +03:00
struct lsa_String lsa_name ;
struct lsa_StringLarge * description = NULL ;
2001-11-22 19:54:48 +03:00
if ( argc ! = 2 ) {
printf ( " Usage: %s privilege name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-11-22 19:54:48 +03:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-22 19:54:48 +03:00
goto done ;
2008-02-11 14:17:27 +03:00
init_lsa_String ( & lsa_name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupPrivDisplayName ( b , mem_ctx ,
2008-02-11 14:17:27 +03:00
& pol ,
& lsa_name ,
lang_id ,
lang_id_sys ,
& description ,
2011-01-18 18:08:05 +03:00
& lang_id_desc ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-22 19:54:48 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-22 19:54:48 +03:00
/* Print results */
2008-02-11 14:17:27 +03:00
printf ( " %s -> %s (language: 0x%x) \n " , argv [ 1 ] , description - > string , lang_id_desc ) ;
2001-11-22 19:54:48 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-11-22 19:54:48 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-11-22 19:54:48 +03:00
}
2001-11-23 02:50:16 +03:00
/* Enumerate the LSA SIDS */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_enum_sids ( struct rpc_pipe_client * cli ,
2003-02-26 02:51:56 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2001-11-23 02:50:16 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-11-23 02:50:16 +03:00
2015-05-09 17:33:08 +03:00
uint32_t enum_context = 0 ;
uint32_t pref_max_length = 0x1000 ;
2008-02-14 03:32:56 +03:00
struct lsa_SidArray sid_array ;
2001-11-23 02:50:16 +03:00
int i ;
if ( argc > 3 ) {
printf ( " Usage: %s [enum context] [max length] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
if ( argc > = 2 )
enum_context = atoi ( argv [ 1 ] ) ;
if ( argc = = 3 )
pref_max_length = atoi ( argv [ 2 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-11-23 02:50:16 +03:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-23 02:50:16 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumAccounts ( b , mem_ctx ,
2008-02-14 03:32:56 +03:00
& pol ,
& enum_context ,
& sid_array ,
2011-01-18 18:08:05 +03:00
pref_max_length ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-23 02:50:16 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-23 02:50:16 +03:00
/* Print results */
2008-02-14 03:32:56 +03:00
printf ( " found %d SIDs \n \n " , sid_array . num_sids ) ;
2001-11-23 02:50:16 +03:00
2008-02-14 03:32:56 +03:00
for ( i = 0 ; i < sid_array . num_sids ; i + + ) {
2001-11-23 02:50:16 +03:00
fstring sid_str ;
2008-02-14 03:32:56 +03:00
sid_to_fstring ( sid_str , sid_array . sids [ i ] . sid ) ;
2001-11-23 02:50:16 +03:00
printf ( " %s \n " , sid_str ) ;
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-11-23 02:50:16 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-11-23 02:50:16 +03:00
}
2005-01-14 22:26:13 +03:00
/* Create a new account */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_create_account ( struct rpc_pipe_client * cli ,
2005-01-14 22:26:13 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol ;
struct policy_handle user_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2015-05-09 17:33:08 +03:00
uint32_t des_access = 0x000f000f ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2010-01-23 15:33:10 +03:00
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2005-01-14 22:26:13 +03:00
if ( argc ! = 2 ) {
printf ( " Usage: %s SID \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2005-01-14 22:26:13 +03:00
goto done ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2005-01-14 22:26:13 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-01-14 22:26:13 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_CreateAccount ( b , mem_ctx ,
2008-02-06 21:07:31 +03:00
& dom_pol ,
& sid ,
des_access ,
2011-01-18 18:08:05 +03:00
& user_pol ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-01-14 22:26:13 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2005-01-14 22:26:13 +03:00
printf ( " Account for SID %s successfully created \n \n " , argv [ 1 ] ) ;
2011-01-18 17:42:47 +03:00
status = NT_STATUS_OK ;
2005-01-14 22:26:13 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2005-01-14 22:26:13 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2005-01-14 22:26:13 +03:00
}
2001-11-24 03:13:41 +03:00
/* Enumerate the privileges of an SID */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_enum_privsaccounts ( struct rpc_pipe_client * cli ,
2001-11-24 03:13:41 +03:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-11-24 03:13:41 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol ;
struct policy_handle user_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2015-05-09 17:33:08 +03:00
uint32_t access_desired = 0x000f000f ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 14:13:13 +03:00
struct lsa_PrivilegeSet * privs = NULL ;
2001-11-24 03:13:41 +03:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-11-24 03:13:41 +03:00
if ( argc ! = 2 ) {
printf ( " Usage: %s SID \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 05:24:12 +03:00
goto done ;
2001-11-24 03:13:41 +03:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-11-24 03:13:41 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-24 03:13:41 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenAccount ( b , mem_ctx ,
2008-02-06 21:31:00 +03:00
& dom_pol ,
& sid ,
access_desired ,
2011-01-18 18:08:05 +03:00
& user_pol ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-24 03:13:41 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-24 03:13:41 +03:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumPrivsAccount ( b , mem_ctx ,
2008-02-14 14:13:13 +03:00
& user_pol ,
2011-01-18 18:08:05 +03:00
& privs ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-24 03:13:41 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-24 03:13:41 +03:00
/* Print results */
2008-02-14 14:13:13 +03:00
printf ( " found %d privileges for SID %s \n \n " , privs - > count , argv [ 1 ] ) ;
2001-11-24 03:13:41 +03:00
printf ( " high \t low \t attribute \n " ) ;
2008-02-14 14:13:13 +03:00
for ( i = 0 ; i < privs - > count ; i + + ) {
printf ( " %u \t %u \t %u \n " ,
privs - > set [ i ] . luid . high ,
privs - > set [ i ] . luid . low ,
privs - > set [ i ] . attribute ) ;
2001-11-24 03:13:41 +03:00
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2001-11-24 03:13:41 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-11-24 03:13:41 +03:00
}
2003-01-15 20:22:48 +03:00
/* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_enum_acct_rights ( struct rpc_pipe_client * cli ,
2003-01-15 20:22:48 +03:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2003-01-15 20:22:48 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 17:09:21 +03:00
struct lsa_RightSet rights ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2003-01-15 20:22:48 +03:00
int i ;
if ( argc ! = 2 ) {
printf ( " Usage: %s SID \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 05:24:12 +03:00
goto done ;
2003-01-15 20:22:48 +03:00
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2003-01-15 20:22:48 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-15 20:22:48 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumAccountRights ( b , mem_ctx ,
2008-02-14 17:09:21 +03:00
& dom_pol ,
& sid ,
2011-01-18 18:08:05 +03:00
& rights ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-15 20:22:48 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2003-01-15 20:22:48 +03:00
2008-02-14 17:09:21 +03:00
printf ( " found %d privileges for SID %s \n " , rights . count ,
2007-12-15 23:53:26 +03:00
sid_string_tos ( & sid ) ) ;
2003-01-15 20:22:48 +03:00
2008-02-14 17:09:21 +03:00
for ( i = 0 ; i < rights . count ; i + + ) {
printf ( " \t %s \n " , rights . names [ i ] . string ) ;
2003-01-15 20:22:48 +03:00
}
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2003-01-15 20:22:48 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2003-01-15 20:22:48 +03:00
}
2003-01-29 00:09:56 +03:00
/* add some privileges to a SID via LsaAddAccountRights */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_add_acct_rights ( struct rpc_pipe_client * cli ,
2003-01-29 00:09:56 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-14 16:34:10 +03:00
struct lsa_RightSet rights ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 16:34:10 +03:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2003-01-29 00:09:56 +03:00
if ( argc < 3 ) {
printf ( " Usage: %s SID [rights...] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 00:09:56 +03:00
goto done ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2003-01-29 00:09:56 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 00:09:56 +03:00
goto done ;
2008-02-14 16:34:10 +03:00
rights . count = argc - 2 ;
2011-06-07 05:30:12 +04:00
rights . names = talloc_array ( mem_ctx , struct lsa_StringLarge ,
2008-02-14 16:34:10 +03:00
rights . count ) ;
if ( ! rights . names ) {
return NT_STATUS_NO_MEMORY ;
}
2008-10-22 16:26:05 +04:00
for ( i = 0 ; i < argc - 2 ; i + + ) {
2008-02-14 16:34:10 +03:00
init_lsa_StringLarge ( & rights . names [ i ] , argv [ i + 2 ] ) ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_AddAccountRights ( b , mem_ctx ,
2008-02-14 16:34:10 +03:00
& dom_pol ,
& sid ,
2011-01-18 18:08:05 +03:00
& rights ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 00:09:56 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2003-01-29 00:09:56 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2003-01-29 00:09:56 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2003-01-29 00:09:56 +03:00
}
2003-01-29 05:24:12 +03:00
/* remove some privileges to a SID via LsaRemoveAccountRights */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_remove_acct_rights ( struct rpc_pipe_client * cli ,
2003-01-29 05:24:12 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-14 17:28:26 +03:00
struct lsa_RightSet rights ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 17:28:26 +03:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2003-01-29 05:24:12 +03:00
if ( argc < 3 ) {
printf ( " Usage: %s SID [rights...] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 05:24:12 +03:00
goto done ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2003-01-29 05:24:12 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 05:24:12 +03:00
goto done ;
2008-02-14 17:28:26 +03:00
rights . count = argc - 2 ;
2011-06-07 05:30:12 +04:00
rights . names = talloc_array ( mem_ctx , struct lsa_StringLarge ,
2008-02-14 17:28:26 +03:00
rights . count ) ;
if ( ! rights . names ) {
return NT_STATUS_NO_MEMORY ;
}
for ( i = 0 ; i < argc - 2 ; i + + ) {
init_lsa_StringLarge ( & rights . names [ i ] , argv [ i + 2 ] ) ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_RemoveAccountRights ( b , mem_ctx ,
2008-02-14 17:28:26 +03:00
& dom_pol ,
& sid ,
false ,
2011-01-18 18:08:05 +03:00
& rights ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2003-01-29 05:24:12 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2003-01-29 05:24:12 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2005-09-30 21:13:37 +04:00
2003-01-29 05:24:12 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2003-01-29 05:24:12 +03:00
}
2001-11-24 03:13:41 +03:00
/* Get a privilege value given its name */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_lookup_priv_value ( struct rpc_pipe_client * cli ,
2003-02-26 02:51:56 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2001-11-24 03:13:41 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-14 15:29:18 +03:00
struct lsa_LUID luid ;
struct lsa_String name ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-11-24 03:13:41 +03:00
if ( argc ! = 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-11-24 03:13:41 +03:00
& pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-24 03:13:41 +03:00
goto done ;
2008-02-14 15:29:18 +03:00
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupPrivValue ( b , mem_ctx ,
2008-02-14 15:29:18 +03:00
& pol ,
& name ,
2011-01-18 18:08:05 +03:00
& luid ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-11-24 03:13:41 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-11-24 03:13:41 +03:00
/* Print results */
2002-07-15 14:35:28 +04:00
2001-11-24 03:13:41 +03:00
printf ( " %u:%u (0x%x:0x%x) \n " , luid . high , luid . low , luid . high , luid . low ) ;
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-11-24 03:13:41 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-11-24 03:13:41 +03:00
}
2001-12-11 05:17:26 +03:00
/* Query LSA security object */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_query_secobj ( struct rpc_pipe_client * cli ,
2001-12-11 05:17:26 +03:00
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-12-11 05:17:26 +03:00
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-18 04:56:17 +04:00
struct sec_desc_buf * sdb ;
2015-05-09 17:33:08 +03:00
uint32_t sec_info = SECINFO_DACL ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2001-12-11 05:17:26 +03:00
2006-03-10 16:01:08 +03:00
if ( argc < 1 | | argc > 2 ) {
printf ( " Usage: %s [sec_info] \n " , argv [ 0 ] ) ;
2001-12-11 05:17:26 +03:00
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2001-12-11 05:17:26 +03:00
& pol ) ;
2006-03-10 16:01:08 +03:00
if ( argc = = 2 )
sscanf ( argv [ 1 ] , " %x " , & sec_info ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-12-11 05:17:26 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QuerySecurity ( b , mem_ctx ,
2008-02-04 23:40:15 +03:00
& pol ,
sec_info ,
2011-01-18 18:08:05 +03:00
& sdb ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2001-12-11 05:17:26 +03:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2001-12-11 05:17:26 +03:00
/* Print results */
2006-09-21 02:23:12 +04:00
display_sec_desc ( sdb - > sd ) ;
2001-12-11 05:17:26 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2001-12-11 05:17:26 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2001-12-11 05:17:26 +03:00
}
2008-04-21 10:01:51 +04:00
static void display_trust_dom_info_4 ( struct lsa_TrustDomainInfoPassword * p ,
2011-07-25 05:21:31 +04:00
DATA_BLOB session_key )
2005-06-08 17:59:03 +04:00
{
char * pwd , * pwd_old ;
2010-01-23 15:33:10 +03:00
2009-03-16 13:27:58 +03:00
DATA_BLOB data = data_blob_const ( p - > password - > data , p - > password - > length ) ;
DATA_BLOB data_old = data_blob_const ( p - > old_password - > data , p - > old_password - > length ) ;
2005-06-08 17:59:03 +04:00
2011-07-25 05:21:31 +04:00
pwd = sess_decrypt_string ( talloc_tos ( ) , & data , & session_key ) ;
pwd_old = sess_decrypt_string ( talloc_tos ( ) , & data_old , & session_key ) ;
2010-01-23 15:33:10 +03:00
2005-06-13 18:39:40 +04:00
d_printf ( " Password: \t %s \n " , pwd ) ;
d_printf ( " Old Password: \t %s \n " , pwd_old ) ;
2005-06-08 17:59:03 +04:00
2009-03-16 13:27:58 +03:00
talloc_free ( pwd ) ;
talloc_free ( pwd_old ) ;
2005-06-08 17:59:03 +04:00
}
2008-01-16 01:06:23 +03:00
static void display_trust_dom_info ( TALLOC_CTX * mem_ctx ,
union lsa_TrustedDomainInfo * info ,
2008-01-14 17:15:47 +03:00
enum lsa_TrustDomInfoEnum info_class ,
2011-07-25 05:21:31 +04:00
DATA_BLOB session_key )
2005-06-08 17:59:03 +04:00
{
switch ( info_class ) {
2008-01-14 17:15:47 +03:00
case LSA_TRUSTED_DOMAIN_INFO_PASSWORD :
2011-07-25 05:21:31 +04:00
display_trust_dom_info_4 ( & info - > password , session_key ) ;
2008-01-14 17:15:47 +03:00
break ;
2008-01-16 01:06:23 +03:00
default : {
const char * str = NULL ;
str = NDR_PRINT_UNION_STRING ( mem_ctx ,
lsa_TrustedDomainInfo ,
info_class , info ) ;
if ( str ) {
d_printf ( " %s \n " , str ) ;
}
2008-01-14 17:15:47 +03:00
break ;
2008-01-16 01:06:23 +03:00
}
2005-06-08 17:59:03 +04:00
}
}
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_query_trustdominfobysid ( struct rpc_pipe_client * cli ,
2005-06-08 17:59:03 +04:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2010-05-21 05:25:01 +04:00
struct dom_sid dom_sid ;
2015-05-09 17:33:08 +03:00
uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED ;
2008-04-09 00:55:52 +04:00
union lsa_TrustedDomainInfo * info = NULL ;
2008-01-14 17:15:47 +03:00
enum lsa_TrustDomInfoEnum info_class = 1 ;
2011-07-25 05:21:31 +04:00
DATA_BLOB session_key ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2005-06-08 17:59:03 +04:00
if ( argc > 3 | | argc < 2 ) {
printf ( " Usage: %s [sid] [info_class] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
if ( ! string_to_sid ( & dom_sid , argv [ 1 ] ) )
return NT_STATUS_NO_MEMORY ;
if ( argc = = 3 )
info_class = atoi ( argv [ 2 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True , access_mask , & pol ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QueryTrustedDomainInfoBySid ( b , mem_ctx ,
2008-01-14 17:15:47 +03:00
& pol ,
& dom_sid ,
info_class ,
2011-01-18 18:08:05 +03:00
& info ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2005-06-08 17:59:03 +04:00
2011-07-25 05:21:31 +04:00
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Could not retrieve session key: %s \n " , nt_errstr ( status ) ) ) ;
2008-04-21 10:01:51 +04:00
goto done ;
}
2011-07-25 05:21:31 +04:00
display_trust_dom_info ( mem_ctx , info , info_class , session_key ) ;
2005-06-08 17:59:03 +04:00
done :
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
return status ;
2005-06-08 17:59:03 +04:00
}
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_query_trustdominfobyname ( struct rpc_pipe_client * cli ,
2005-06-08 17:59:03 +04:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2015-05-09 17:33:08 +03:00
uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED ;
2008-04-09 01:09:24 +04:00
union lsa_TrustedDomainInfo * info = NULL ;
2008-01-14 17:15:47 +03:00
enum lsa_TrustDomInfoEnum info_class = 1 ;
struct lsa_String trusted_domain ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2011-07-25 05:21:31 +04:00
DATA_BLOB session_key ;
2005-06-08 17:59:03 +04:00
if ( argc > 3 | | argc < 2 ) {
printf ( " Usage: %s [name] [info_class] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
if ( argc = = 3 )
info_class = atoi ( argv [ 2 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True , access_mask , & pol ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2008-01-14 17:15:47 +03:00
init_lsa_String ( & trusted_domain , argv [ 1 ] ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QueryTrustedDomainInfoByName ( b , mem_ctx ,
2008-01-14 17:15:47 +03:00
& pol ,
2008-02-08 20:02:57 +03:00
& trusted_domain ,
2008-01-14 17:15:47 +03:00
info_class ,
2011-01-18 18:08:05 +03:00
& info ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2005-06-08 17:59:03 +04:00
2011-07-25 05:21:31 +04:00
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Could not retrieve session key: %s \n " , nt_errstr ( status ) ) ) ;
2008-04-21 10:01:51 +04:00
goto done ;
}
2011-07-25 05:21:31 +04:00
display_trust_dom_info ( mem_ctx , info , info_class , session_key ) ;
2005-06-08 17:59:03 +04:00
done :
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
return status ;
2005-06-08 17:59:03 +04:00
}
2011-11-22 21:38:52 +04:00
static NTSTATUS cmd_lsa_set_trustdominfo ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
struct policy_handle pol , trustdom_pol ;
NTSTATUS status , result ;
2015-05-09 17:33:08 +03:00
uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED ;
2011-11-22 21:38:52 +04:00
union lsa_TrustedDomainInfo info ;
struct dom_sid dom_sid ;
enum lsa_TrustDomInfoEnum info_class = 1 ;
struct dcerpc_binding_handle * b = cli - > binding_handle ;
if ( argc > 4 | | argc < 3 ) {
printf ( " Usage: %s [sid] [info_class] [value] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
if ( ! string_to_sid ( & dom_sid , argv [ 1 ] ) ) {
return NT_STATUS_NO_MEMORY ;
}
info_class = atoi ( argv [ 2 ] ) ;
switch ( info_class ) {
case 13 : /* LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES */
info . enc_types . enc_types = atoi ( argv [ 3 ] ) ;
break ;
default :
return NT_STATUS_INVALID_PARAMETER ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True , access_mask , & pol ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
status = dcerpc_lsa_OpenTrustedDomain ( b , mem_ctx ,
& pol ,
& dom_sid ,
access_mask ,
& trustdom_pol ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
status = dcerpc_lsa_SetInformationTrustedDomain ( b , mem_ctx ,
& trustdom_pol ,
info_class ,
& info ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
done :
dcerpc_lsa_Close ( b , mem_ctx , & trustdom_pol , & result ) ;
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
return status ;
}
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_lsa_query_trustdominfo ( struct rpc_pipe_client * cli ,
2005-06-08 17:59:03 +04:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle pol , trustdom_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2015-05-09 17:33:08 +03:00
uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED ;
2008-04-09 00:55:52 +04:00
union lsa_TrustedDomainInfo * info = NULL ;
2010-05-21 05:25:01 +04:00
struct dom_sid dom_sid ;
2008-01-14 17:15:47 +03:00
enum lsa_TrustDomInfoEnum info_class = 1 ;
2011-07-25 05:21:31 +04:00
DATA_BLOB session_key ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2005-06-08 17:59:03 +04:00
if ( argc > 3 | | argc < 2 ) {
printf ( " Usage: %s [sid] [info_class] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
if ( ! string_to_sid ( & dom_sid , argv [ 1 ] ) )
return NT_STATUS_NO_MEMORY ;
if ( argc = = 3 )
info_class = atoi ( argv [ 2 ] ) ;
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True , access_mask , & pol ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2008-01-14 17:27:57 +03:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenTrustedDomain ( b , mem_ctx ,
2008-01-14 17:27:57 +03:00
& pol ,
& dom_sid ,
access_mask ,
2011-01-18 18:08:05 +03:00
& trustdom_pol ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2005-06-08 17:59:03 +04:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QueryTrustedDomainInfo ( b , mem_ctx ,
2008-01-14 17:15:47 +03:00
& trustdom_pol ,
info_class ,
2011-01-18 18:08:05 +03:00
& info ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
2005-06-08 17:59:03 +04:00
goto done ;
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2005-06-08 17:59:03 +04:00
2011-07-25 05:21:31 +04:00
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 0 , ( " Could not retrieve session key: %s \n " , nt_errstr ( status ) ) ) ;
2008-04-21 10:01:51 +04:00
goto done ;
}
2011-07-25 05:21:31 +04:00
display_trust_dom_info ( mem_ctx , info , info_class , session_key ) ;
2005-06-08 17:59:03 +04:00
done :
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & pol , & result ) ;
2005-06-08 17:59:03 +04:00
2011-01-18 17:42:47 +03:00
return status ;
2005-06-08 17:59:03 +04:00
}
2008-02-11 22:22:01 +03:00
static NTSTATUS cmd_lsa_get_username ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-04-19 23:56:43 +04:00
const char * servername = cli - > desthost ;
2008-02-11 22:22:01 +03:00
struct lsa_String * account_name = NULL ;
struct lsa_String * authority_name = NULL ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2008-02-11 22:22:01 +03:00
if ( argc > 2 ) {
printf ( " Usage: %s servername \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_GetUserName ( b , mem_ctx ,
2008-02-11 22:22:01 +03:00
servername ,
& account_name ,
2011-01-18 18:08:05 +03:00
& authority_name ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-11 22:22:01 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2008-02-11 22:22:01 +03:00
/* Print results */
printf ( " Account Name: %s, Authority Name: %s \n " ,
2008-10-21 03:19:49 +04:00
account_name - > string , authority_name ? authority_name - > string :
" " ) ;
2008-02-11 22:22:01 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2008-02-11 22:22:01 +03:00
}
2005-06-08 17:59:03 +04:00
2008-02-14 15:46:39 +03:00
static NTSTATUS cmd_lsa_add_priv ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol , user_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-14 15:46:39 +03:00
struct lsa_PrivilegeSet privs ;
struct lsa_LUIDAttribute * set = NULL ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 15:46:39 +03:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2008-02-14 15:46:39 +03:00
ZERO_STRUCT ( privs ) ;
if ( argc < 3 ) {
printf ( " Usage: %s SID [rights...] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2008-02-14 15:46:39 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenAccount ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& dom_pol ,
& sid ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& user_pol ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2008-02-14 15:46:39 +03:00
for ( i = 2 ; i < argc ; i + + ) {
struct lsa_String priv_name ;
struct lsa_LUID luid ;
init_lsa_String ( & priv_name , argv [ i ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupPrivValue ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& dom_pol ,
& priv_name ,
2011-01-18 18:08:05 +03:00
& luid ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
continue ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
continue ;
}
2008-02-14 15:46:39 +03:00
privs . count + + ;
2011-06-07 05:10:15 +04:00
set = talloc_realloc ( mem_ctx , set ,
2008-02-14 15:46:39 +03:00
struct lsa_LUIDAttribute ,
privs . count ) ;
if ( ! set ) {
return NT_STATUS_NO_MEMORY ;
}
set [ privs . count - 1 ] . luid = luid ;
set [ privs . count - 1 ] . attribute = 0 ;
}
privs . set = set ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_AddPrivilegesToAccount ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& user_pol ,
2011-01-18 18:08:05 +03:00
& privs ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2008-02-14 15:46:39 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & user_pol , & result ) ;
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2008-02-14 15:46:39 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2008-02-14 15:46:39 +03:00
}
static NTSTATUS cmd_lsa_del_priv ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2009-03-19 00:49:41 +03:00
struct policy_handle dom_pol , user_pol ;
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2008-02-14 15:46:39 +03:00
struct lsa_PrivilegeSet privs ;
struct lsa_LUIDAttribute * set = NULL ;
2010-05-21 05:25:01 +04:00
struct dom_sid sid ;
2008-02-14 15:46:39 +03:00
int i ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2008-02-14 15:46:39 +03:00
ZERO_STRUCT ( privs ) ;
if ( argc < 3 ) {
printf ( " Usage: %s SID [rights...] \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
2011-01-18 17:42:47 +03:00
status = name_to_sid ( cli , mem_ctx , & sid , argv [ 1 ] ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 17:42:47 +03:00
status = rpccli_lsa_open_policy2 ( cli , mem_ctx , True ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2008-02-14 15:46:39 +03:00
& dom_pol ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenAccount ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& dom_pol ,
& sid ,
2009-04-15 03:12:13 +04:00
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& user_pol ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2008-02-14 15:46:39 +03:00
for ( i = 2 ; i < argc ; i + + ) {
struct lsa_String priv_name ;
struct lsa_LUID luid ;
init_lsa_String ( & priv_name , argv [ i ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_LookupPrivValue ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& dom_pol ,
& priv_name ,
2011-01-18 18:08:05 +03:00
& luid ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
continue ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
continue ;
}
2008-02-14 15:46:39 +03:00
privs . count + + ;
2011-06-07 05:10:15 +04:00
set = talloc_realloc ( mem_ctx , set ,
2008-02-14 15:46:39 +03:00
struct lsa_LUIDAttribute ,
privs . count ) ;
if ( ! set ) {
return NT_STATUS_NO_MEMORY ;
}
set [ privs . count - 1 ] . luid = luid ;
set [ privs . count - 1 ] . attribute = 0 ;
}
privs . set = set ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_RemovePrivilegesFromAccount ( b , mem_ctx ,
2008-02-14 15:46:39 +03:00
& user_pol ,
false ,
2011-01-18 18:08:05 +03:00
& privs ,
& result ) ;
2011-01-18 17:42:47 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2008-02-14 15:46:39 +03:00
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2008-02-14 15:46:39 +03:00
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & user_pol , & result ) ;
dcerpc_lsa_Close ( b , mem_ctx , & dom_pol , & result ) ;
2008-02-14 15:46:39 +03:00
done :
2011-01-18 17:42:47 +03:00
return status ;
2008-02-14 15:46:39 +03:00
}
2009-07-17 13:54:49 +04:00
static NTSTATUS cmd_lsa_create_secret ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 13:54:49 +04:00
struct policy_handle handle , sec_handle ;
struct lsa_String name ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 13:54:49 +04:00
if ( argc < 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_CreateSecret ( b , mem_ctx ,
2009-07-17 13:54:49 +04:00
& handle ,
name ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& sec_handle ,
& result ) ;
2009-07-17 13:54:49 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 13:54:49 +04:00
done :
if ( is_valid_policy_hnd ( & sec_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & sec_handle , & result ) ;
2009-07-17 13:54:49 +04:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 13:54:49 +04:00
}
return status ;
}
2002-10-04 08:10:23 +04:00
2009-07-17 13:58:10 +04:00
static NTSTATUS cmd_lsa_delete_secret ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 13:58:10 +04:00
struct policy_handle handle , sec_handle ;
struct lsa_String name ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 13:58:10 +04:00
if ( argc < 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenSecret ( b , mem_ctx ,
2009-07-17 13:58:10 +04:00
& handle ,
name ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& sec_handle ,
& result ) ;
2009-07-17 13:58:10 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 13:58:10 +04:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_DeleteObject ( b , mem_ctx ,
& sec_handle ,
& result ) ;
2009-07-17 13:58:10 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 13:58:10 +04:00
done :
if ( is_valid_policy_hnd ( & sec_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & sec_handle , & result ) ;
2009-07-17 13:58:10 +04:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 13:58:10 +04:00
}
return status ;
}
2009-07-17 14:03:58 +04:00
static NTSTATUS cmd_lsa_query_secret ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 14:03:58 +04:00
struct policy_handle handle , sec_handle ;
struct lsa_String name ;
struct lsa_DATA_BUF_PTR new_val ;
NTTIME new_mtime = 0 ;
struct lsa_DATA_BUF_PTR old_val ;
NTTIME old_mtime = 0 ;
DATA_BLOB session_key ;
DATA_BLOB new_blob = data_blob_null ;
DATA_BLOB old_blob = data_blob_null ;
char * new_secret , * old_secret ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 14:03:58 +04:00
if ( argc < 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenSecret ( b , mem_ctx ,
2009-07-17 14:03:58 +04:00
& handle ,
name ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& sec_handle ,
& result ) ;
2009-07-17 14:03:58 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 14:03:58 +04:00
ZERO_STRUCT ( new_val ) ;
ZERO_STRUCT ( old_val ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_QuerySecret ( b , mem_ctx ,
2009-07-17 14:03:58 +04:00
& sec_handle ,
& new_val ,
& new_mtime ,
& old_val ,
2011-01-18 18:08:05 +03:00
& old_mtime ,
& result ) ;
2009-07-17 14:03:58 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 14:03:58 +04:00
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( new_val . buf ) {
new_blob = data_blob_const ( new_val . buf - > data , new_val . buf - > length ) ;
}
if ( old_val . buf ) {
old_blob = data_blob_const ( old_val . buf - > data , old_val . buf - > length ) ;
}
new_secret = sess_decrypt_string ( mem_ctx , & new_blob , & session_key ) ;
old_secret = sess_decrypt_string ( mem_ctx , & old_blob , & session_key ) ;
if ( new_secret ) {
d_printf ( " new secret: %s \n " , new_secret ) ;
}
if ( old_secret ) {
d_printf ( " old secret: %s \n " , old_secret ) ;
}
done :
if ( is_valid_policy_hnd ( & sec_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & sec_handle , & result ) ;
2009-07-17 14:03:58 +04:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 14:03:58 +04:00
}
return status ;
}
2009-07-17 14:56:30 +04:00
static NTSTATUS cmd_lsa_set_secret ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 14:56:30 +04:00
struct policy_handle handle , sec_handle ;
struct lsa_String name ;
struct lsa_DATA_BUF new_val ;
struct lsa_DATA_BUF old_val ;
DATA_BLOB enc_key ;
DATA_BLOB session_key ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 14:56:30 +04:00
if ( argc < 3 ) {
printf ( " Usage: %s name secret \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenSecret ( b , mem_ctx ,
2009-07-17 14:56:30 +04:00
& handle ,
name ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& sec_handle ,
& result ) ;
2009-07-17 14:56:30 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 14:56:30 +04:00
ZERO_STRUCT ( new_val ) ;
ZERO_STRUCT ( old_val ) ;
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
enc_key = sess_encrypt_string ( argv [ 2 ] , & session_key ) ;
new_val . length = enc_key . length ;
new_val . size = enc_key . length ;
new_val . data = enc_key . data ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_SetSecret ( b , mem_ctx ,
2009-07-17 14:56:30 +04:00
& sec_handle ,
& new_val ,
2011-01-18 18:08:05 +03:00
NULL ,
& result ) ;
2009-07-17 14:56:30 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 14:56:30 +04:00
done :
if ( is_valid_policy_hnd ( & sec_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & sec_handle , & result ) ;
2009-07-17 14:56:30 +04:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 14:56:30 +04:00
}
return status ;
}
2009-07-17 15:30:37 +04:00
static NTSTATUS cmd_lsa_retrieve_private_data ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 15:30:37 +04:00
struct policy_handle handle ;
struct lsa_String name ;
struct lsa_DATA_BUF * val ;
DATA_BLOB session_key ;
2009-09-16 12:14:05 +04:00
DATA_BLOB blob = data_blob_null ;
2009-07-17 15:30:37 +04:00
char * secret ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 15:30:37 +04:00
if ( argc < 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
ZERO_STRUCT ( val ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_RetrievePrivateData ( b , mem_ctx ,
2009-07-17 15:30:37 +04:00
& handle ,
& name ,
2011-01-18 18:08:05 +03:00
& val ,
& result ) ;
2009-07-17 15:30:37 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 15:30:37 +04:00
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( val ) {
blob = data_blob_const ( val - > data , val - > length ) ;
}
secret = sess_decrypt_string ( mem_ctx , & blob , & session_key ) ;
if ( secret ) {
d_printf ( " secret: %s \n " , secret ) ;
}
done :
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 15:30:37 +04:00
}
return status ;
}
2009-07-17 15:37:08 +04:00
static NTSTATUS cmd_lsa_store_private_data ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-07-17 15:37:08 +04:00
struct policy_handle handle ;
struct lsa_String name ;
struct lsa_DATA_BUF val ;
DATA_BLOB session_key ;
DATA_BLOB enc_key ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-07-17 15:37:08 +04:00
if ( argc < 3 ) {
printf ( " Usage: %s name secret \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
ZERO_STRUCT ( val ) ;
status = cli_get_session_key ( mem_ctx , cli , & session_key ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
enc_key = sess_encrypt_string ( argv [ 2 ] , & session_key ) ;
val . length = enc_key . length ;
val . size = enc_key . length ;
val . data = enc_key . data ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_StorePrivateData ( b , mem_ctx ,
2009-07-17 15:37:08 +04:00
& handle ,
& name ,
2011-01-18 18:08:05 +03:00
& val ,
& result ) ;
2009-07-17 15:37:08 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-07-17 15:37:08 +04:00
done :
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-07-17 15:37:08 +04:00
}
return status ;
}
2009-10-28 16:13:32 +03:00
static NTSTATUS cmd_lsa_create_trusted_domain ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-10-28 16:13:32 +03:00
struct policy_handle handle , trustdom_handle ;
2010-01-23 15:18:00 +03:00
struct dom_sid sid ;
2009-10-28 16:13:32 +03:00
struct lsa_DomainInfo info ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-10-28 16:13:32 +03:00
if ( argc < 3 ) {
printf ( " Usage: %s name sid \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_StringLarge ( & info . name , argv [ 1 ] ) ;
2010-01-23 15:18:00 +03:00
info . sid = & sid ;
string_to_sid ( & sid , argv [ 2 ] ) ;
2009-10-28 16:13:32 +03:00
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_CreateTrustedDomain ( b , mem_ctx ,
2009-10-28 16:13:32 +03:00
& handle ,
& info ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& trustdom_handle ,
& result ) ;
2009-10-28 16:13:32 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-10-28 16:13:32 +03:00
done :
if ( is_valid_policy_hnd ( & trustdom_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & trustdom_handle , & result ) ;
2009-10-28 16:13:32 +03:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-10-28 16:13:32 +03:00
}
return status ;
}
2009-07-17 14:56:30 +04:00
2009-10-28 17:37:11 +03:00
static NTSTATUS cmd_lsa_delete_trusted_domain ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
2011-01-18 18:08:05 +03:00
NTSTATUS status , result ;
2009-10-28 17:37:11 +03:00
struct policy_handle handle , trustdom_handle ;
struct lsa_String name ;
struct dom_sid * sid = NULL ;
2011-01-18 18:08:05 +03:00
struct dcerpc_binding_handle * b = cli - > binding_handle ;
2009-10-28 17:37:11 +03:00
if ( argc < 2 ) {
printf ( " Usage: %s name \n " , argv [ 0 ] ) ;
return NT_STATUS_OK ;
}
status = rpccli_lsa_open_policy2 ( cli , mem_ctx ,
true ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return status ;
}
init_lsa_String ( & name , argv [ 1 ] ) ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenTrustedDomainByName ( b , mem_ctx ,
2009-10-28 17:37:11 +03:00
& handle ,
name ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& trustdom_handle ,
& result ) ;
if ( NT_STATUS_IS_OK ( status ) & & NT_STATUS_IS_OK ( result ) ) {
2009-10-28 17:37:11 +03:00
goto delete_object ;
}
{
uint32_t resume_handle = 0 ;
struct lsa_DomainList domains ;
int i ;
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_EnumTrustDom ( b , mem_ctx ,
2009-10-28 17:37:11 +03:00
& handle ,
& resume_handle ,
& domains ,
2011-01-18 18:08:05 +03:00
0xffff ,
& result ) ;
2009-10-28 17:37:11 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-10-28 17:37:11 +03:00
for ( i = 0 ; i < domains . count ; i + + ) {
if ( strequal ( domains . domains [ i ] . name . string , argv [ 1 ] ) ) {
sid = domains . domains [ i ] . sid ;
break ;
}
}
if ( ! sid ) {
return NT_STATUS_INVALID_SID ;
}
}
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_OpenTrustedDomain ( b , mem_ctx ,
2009-10-28 17:37:11 +03:00
& handle ,
sid ,
SEC_FLAG_MAXIMUM_ALLOWED ,
2011-01-18 18:08:05 +03:00
& trustdom_handle ,
& result ) ;
2009-10-28 17:37:11 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-10-28 17:37:11 +03:00
delete_object :
2011-01-18 18:08:05 +03:00
status = dcerpc_lsa_DeleteObject ( b , mem_ctx ,
& trustdom_handle ,
& result ) ;
2009-10-28 17:37:11 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
2011-01-18 18:08:05 +03:00
if ( ! NT_STATUS_IS_OK ( result ) ) {
status = result ;
goto done ;
}
2009-10-28 17:37:11 +03:00
done :
if ( is_valid_policy_hnd ( & trustdom_handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & trustdom_handle , & result ) ;
2009-10-28 17:37:11 +03:00
}
if ( is_valid_policy_hnd ( & handle ) ) {
2011-01-18 18:08:05 +03:00
dcerpc_lsa_Close ( b , mem_ctx , & handle , & result ) ;
2009-10-28 17:37:11 +03:00
}
return status ;
}
2001-01-12 01:49:30 +03:00
/* List of commands exported by this module */
struct cmd_set lsarpc_commands [ ] = {
2001-07-20 08:38:58 +04:00
{ " LSARPC " } ,
2012-01-10 14:53:42 +04:00
{ " lsaquery " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_info_policy , NULL , & ndr_table_lsarpc , NULL , " Query info policy " , " " } ,
{ " lookupsids " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_sids , NULL , & ndr_table_lsarpc , NULL , " Convert SIDs to names " , " " } ,
{ " lookupsids3 " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_sids3 , NULL , & ndr_table_lsarpc , NULL , " Convert SIDs to names " , " " } ,
{ " lookupnames " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_names , NULL , & ndr_table_lsarpc , NULL , " Convert names to SIDs " , " " } ,
{ " lookupnames4 " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_names4 , NULL , & ndr_table_lsarpc , NULL , " Convert names to SIDs " , " " } ,
{ " lookupnames_level " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_names_level , NULL , & ndr_table_lsarpc , NULL , " Convert names to SIDs " , " " } ,
{ " enumtrust " , RPC_RTYPE_NTSTATUS , cmd_lsa_enum_trust_dom , NULL , & ndr_table_lsarpc , NULL , " Enumerate trusted domains " , " Usage: [preferred max number] [enum context (0)] " } ,
{ " enumprivs " , RPC_RTYPE_NTSTATUS , cmd_lsa_enum_privilege , NULL , & ndr_table_lsarpc , NULL , " Enumerate privileges " , " " } ,
{ " getdispname " , RPC_RTYPE_NTSTATUS , cmd_lsa_get_dispname , NULL , & ndr_table_lsarpc , NULL , " Get the privilege name " , " " } ,
{ " lsaenumsid " , RPC_RTYPE_NTSTATUS , cmd_lsa_enum_sids , NULL , & ndr_table_lsarpc , NULL , " Enumerate the LSA SIDS " , " " } ,
{ " lsacreateaccount " , RPC_RTYPE_NTSTATUS , cmd_lsa_create_account , NULL , & ndr_table_lsarpc , NULL , " Create a new lsa account " , " " } ,
{ " lsaenumprivsaccount " , RPC_RTYPE_NTSTATUS , cmd_lsa_enum_privsaccounts , NULL , & ndr_table_lsarpc , NULL , " Enumerate the privileges of an SID " , " " } ,
{ " lsaenumacctrights " , RPC_RTYPE_NTSTATUS , cmd_lsa_enum_acct_rights , NULL , & ndr_table_lsarpc , NULL , " Enumerate the rights of an SID " , " " } ,
{ " lsaaddpriv " , RPC_RTYPE_NTSTATUS , cmd_lsa_add_priv , NULL , & ndr_table_lsarpc , NULL , " Assign a privilege to a SID " , " " } ,
{ " lsadelpriv " , RPC_RTYPE_NTSTATUS , cmd_lsa_del_priv , NULL , & ndr_table_lsarpc , NULL , " Revoke a privilege from a SID " , " " } ,
{ " lsaaddacctrights " , RPC_RTYPE_NTSTATUS , cmd_lsa_add_acct_rights , NULL , & ndr_table_lsarpc , NULL , " Add rights to an account " , " " } ,
{ " lsaremoveacctrights " , RPC_RTYPE_NTSTATUS , cmd_lsa_remove_acct_rights , NULL , & ndr_table_lsarpc , NULL , " Remove rights from an account " , " " } ,
{ " lsalookupprivvalue " , RPC_RTYPE_NTSTATUS , cmd_lsa_lookup_priv_value , NULL , & ndr_table_lsarpc , NULL , " Get a privilege value given its name " , " " } ,
{ " lsaquerysecobj " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_secobj , NULL , & ndr_table_lsarpc , NULL , " Query LSA security object " , " " } ,
{ " lsaquerytrustdominfo " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_trustdominfo , NULL , & ndr_table_lsarpc , NULL , " Query LSA trusted domains info (given a SID) " , " " } ,
{ " lsaquerytrustdominfobyname " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_trustdominfobyname , NULL , & ndr_table_lsarpc , NULL , " Query LSA trusted domains info (given a name), only works for Windows > 2k " , " " } ,
{ " lsaquerytrustdominfobysid " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_trustdominfobysid , NULL , & ndr_table_lsarpc , NULL , " Query LSA trusted domains info (given a SID) " , " " } ,
{ " lsasettrustdominfo " , RPC_RTYPE_NTSTATUS , cmd_lsa_set_trustdominfo , NULL , & ndr_table_lsarpc , NULL , " Set LSA trusted domain info " , " " } ,
{ " getusername " , RPC_RTYPE_NTSTATUS , cmd_lsa_get_username , NULL , & ndr_table_lsarpc , NULL , " Get username " , " " } ,
{ " createsecret " , RPC_RTYPE_NTSTATUS , cmd_lsa_create_secret , NULL , & ndr_table_lsarpc , NULL , " Create Secret " , " " } ,
{ " deletesecret " , RPC_RTYPE_NTSTATUS , cmd_lsa_delete_secret , NULL , & ndr_table_lsarpc , NULL , " Delete Secret " , " " } ,
{ " querysecret " , RPC_RTYPE_NTSTATUS , cmd_lsa_query_secret , NULL , & ndr_table_lsarpc , NULL , " Query Secret " , " " } ,
{ " setsecret " , RPC_RTYPE_NTSTATUS , cmd_lsa_set_secret , NULL , & ndr_table_lsarpc , NULL , " Set Secret " , " " } ,
{ " retrieveprivatedata " , RPC_RTYPE_NTSTATUS , cmd_lsa_retrieve_private_data , NULL , & ndr_table_lsarpc , NULL , " Retrieve Private Data " , " " } ,
{ " storeprivatedata " , RPC_RTYPE_NTSTATUS , cmd_lsa_store_private_data , NULL , & ndr_table_lsarpc , NULL , " Store Private Data " , " " } ,
{ " createtrustdom " , RPC_RTYPE_NTSTATUS , cmd_lsa_create_trusted_domain , NULL , & ndr_table_lsarpc , NULL , " Create Trusted Domain " , " " } ,
{ " deletetrustdom " , RPC_RTYPE_NTSTATUS , cmd_lsa_delete_trusted_domain , NULL , & ndr_table_lsarpc , NULL , " Delete Trusted Domain " , " " } ,
2009-11-08 21:38:09 +03:00
2001-07-20 08:38:58 +04:00
{ NULL }
2001-01-12 01:49:30 +03:00
} ;
2005-01-15 05:20:30 +03:00