1998-09-26 01:01:52 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-05-24 04:20:32 +04:00
RPC pipe client
Copyright ( C ) Tim Potter 2000
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 .
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 .
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"
1998-09-26 01:01:52 +04:00
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_logon_ctrl2 ( 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-05-24 12:10:50 +04:00
{
uint32 query_level = 1 ;
2001-09-04 14:57:29 +04:00
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
2001-05-24 12:10:50 +04:00
if ( argc > 1 ) {
2001-10-12 09:56:23 +04:00
fprintf ( stderr , " Usage: %s \n " , argv [ 0 ] ) ;
2001-09-04 14:57:29 +04:00
return NT_STATUS_OK ;
2001-05-24 12:10:50 +04:00
}
2005-09-30 21:13:37 +04:00
result = rpccli_netlogon_logon_ctrl2 ( cli , mem_ctx , query_level ) ;
2001-10-12 09:56:23 +04:00
if ( ! NT_STATUS_IS_OK ( result ) )
2001-05-24 12:10:50 +04:00
goto done ;
/* Display results */
done :
return result ;
}
2007-05-29 19:27:13 +04:00
static WERROR cmd_netlogon_getanydcname ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2004-04-02 16:56:18 +04:00
{
2007-12-21 17:12:40 +03:00
char * dcname = NULL ;
2006-10-06 20:13:10 +04:00
WERROR result = WERR_GENERAL_FAILURE ;
2006-10-07 09:26:21 +04:00
int old_timeout ;
2004-04-02 16:56:18 +04:00
if ( argc ! = 2 ) {
fprintf ( stderr , " Usage: %s domainname \n " , argv [ 0 ] ) ;
2006-10-06 20:13:10 +04:00
return WERR_OK ;
2004-04-02 16:56:18 +04:00
}
2006-10-07 09:26:21 +04:00
/* Make sure to wait for our DC's reply */
2006-10-17 03:27:38 +04:00
old_timeout = cli_set_timeout ( cli - > cli , MAX ( cli - > cli - > timeout , 30000 ) ) ; /* 30 seconds. */
2006-10-07 09:26:21 +04:00
2007-12-21 17:12:40 +03:00
result = rpccli_netlogon_getanydcname ( cli , mem_ctx , cli - > cli - > desthost , argv [ 1 ] , & dcname ) ;
2004-04-02 16:56:18 +04:00
2006-10-07 09:26:21 +04:00
cli_set_timeout ( cli - > cli , old_timeout ) ;
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Display results */
printf ( " %s \n " , dcname ) ;
done :
return result ;
}
2007-06-08 14:29:46 +04:00
static WERROR cmd_netlogon_getdcname ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2006-10-07 09:26:21 +04:00
{
2007-12-21 17:12:40 +03:00
char * dcname = NULL ;
2007-06-08 14:29:46 +04:00
WERROR result = WERR_GENERAL_FAILURE ;
2006-10-07 09:26:21 +04:00
int old_timeout ;
if ( argc ! = 2 ) {
fprintf ( stderr , " Usage: %s domainname \n " , argv [ 0 ] ) ;
2007-06-08 14:29:46 +04:00
return WERR_OK ;
2006-10-07 09:26:21 +04:00
}
/* Make sure to wait for our DC's reply */
2006-10-17 03:27:38 +04:00
old_timeout = cli_set_timeout ( cli - > cli , MAX ( cli - > cli - > timeout , 30000 ) ) ; /* 30 seconds. */
2006-10-07 09:26:21 +04:00
2007-12-21 17:12:40 +03:00
result = rpccli_netlogon_getdcname ( cli , mem_ctx , cli - > cli - > desthost , argv [ 1 ] , & dcname ) ;
2006-10-07 09:26:21 +04:00
cli_set_timeout ( cli - > cli , old_timeout ) ;
2007-06-08 14:29:46 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
2004-04-02 16:56:18 +04:00
goto done ;
/* Display results */
printf ( " %s \n " , dcname ) ;
done :
return result ;
}
2005-11-13 14:38:17 +03:00
static WERROR cmd_netlogon_dsr_getdcname ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR result ;
2007-05-25 03:11:11 +04:00
uint32 flags = DS_RETURN_DNS_NAME ;
const char * server_name = cli - > cli - > desthost ;
const char * domain_name ;
struct GUID domain_guid = GUID_zero ( ) ;
struct GUID site_guid = GUID_zero ( ) ;
struct DS_DOMAIN_CONTROLLER_INFO * info = NULL ;
if ( argc < 2 ) {
2007-08-28 19:01:23 +04:00
fprintf ( stderr , " Usage: %s [domain_name] [domain_guid] "
" [site_guid] [flags] \n " , argv [ 0 ] ) ;
2005-11-13 14:38:17 +03:00
return WERR_OK ;
}
2007-05-25 03:11:11 +04:00
if ( argc > = 2 )
domain_name = argv [ 1 ] ;
if ( argc > = 3 ) {
if ( ! NT_STATUS_IS_OK ( GUID_from_string ( argv [ 2 ] , & domain_guid ) ) ) {
return WERR_NOMEM ;
}
}
if ( argc > = 4 ) {
if ( ! NT_STATUS_IS_OK ( GUID_from_string ( argv [ 3 ] , & site_guid ) ) ) {
return WERR_NOMEM ;
}
}
if ( argc > = 5 )
sscanf ( argv [ 4 ] , " %x " , & flags ) ;
2007-08-28 19:01:23 +04:00
debug_dsdcinfo_flags ( 1 , flags ) ;
2007-05-25 03:11:11 +04:00
result = rpccli_netlogon_dsr_getdcname ( cli , mem_ctx , server_name , domain_name ,
& domain_guid , & site_guid , flags ,
& info ) ;
2005-11-13 14:38:17 +03:00
if ( W_ERROR_IS_OK ( result ) ) {
2007-05-25 03:11:11 +04:00
d_printf ( " DsGetDcName gave \n " ) ;
display_ds_domain_controller_info ( mem_ctx , info ) ;
2005-11-13 14:38:17 +03:00
return WERR_OK ;
}
printf ( " rpccli_netlogon_dsr_getdcname returned %s \n " ,
2007-05-25 03:11:11 +04:00
dos_errstr ( result ) ) ;
return result ;
}
static WERROR cmd_netlogon_dsr_getdcnameex ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR result ;
uint32 flags = DS_RETURN_DNS_NAME ;
const char * server_name = cli - > cli - > desthost ;
const char * domain_name ;
const char * site_name = NULL ;
struct GUID domain_guid = GUID_zero ( ) ;
struct DS_DOMAIN_CONTROLLER_INFO * info = NULL ;
if ( argc < 2 ) {
2007-08-28 19:01:23 +04:00
fprintf ( stderr , " Usage: %s [domain_name] [domain_guid] "
" [site_name] [flags] \n " , argv [ 0 ] ) ;
2007-05-25 03:11:11 +04:00
return WERR_OK ;
}
if ( argc > = 2 )
domain_name = argv [ 1 ] ;
if ( argc > = 3 ) {
if ( ! NT_STATUS_IS_OK ( GUID_from_string ( argv [ 2 ] , & domain_guid ) ) ) {
return WERR_NOMEM ;
}
}
if ( argc > = 4 )
site_name = argv [ 3 ] ;
if ( argc > = 5 )
sscanf ( argv [ 4 ] , " %x " , & flags ) ;
2007-08-28 19:01:23 +04:00
debug_dsdcinfo_flags ( 1 , flags ) ;
2007-05-25 03:11:11 +04:00
result = rpccli_netlogon_dsr_getdcnameex ( cli , mem_ctx , server_name , domain_name ,
& domain_guid , site_name , flags ,
& info ) ;
if ( W_ERROR_IS_OK ( result ) ) {
d_printf ( " DsGetDcNameEx gave \n " ) ;
display_ds_domain_controller_info ( mem_ctx , info ) ;
return WERR_OK ;
}
printf ( " rpccli_netlogon_dsr_getdcnameex returned %s \n " ,
dos_errstr ( result ) ) ;
return result ;
}
static WERROR cmd_netlogon_dsr_getdcnameex2 ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR result ;
uint32 flags = DS_RETURN_DNS_NAME ;
const char * server_name = cli - > cli - > desthost ;
2007-05-29 21:57:52 +04:00
const char * domain_name = NULL ;
2007-05-25 03:11:11 +04:00
const char * client_account = NULL ;
uint32 mask = 0 ;
const char * site_name = NULL ;
struct GUID domain_guid = GUID_zero ( ) ;
struct DS_DOMAIN_CONTROLLER_INFO * info = NULL ;
if ( argc < 2 ) {
2007-08-28 19:01:23 +04:00
fprintf ( stderr , " Usage: %s [client_account] [acb_mask] "
" [domain_name] [domain_guid] [site_name] "
" [flags] \n " , argv [ 0 ] ) ;
2007-05-25 03:11:11 +04:00
return WERR_OK ;
}
if ( argc > = 2 )
client_account = argv [ 1 ] ;
if ( argc > = 3 )
mask = atoi ( argv [ 2 ] ) ;
2007-08-28 19:01:23 +04:00
2007-05-25 03:11:11 +04:00
if ( argc > = 4 )
domain_name = argv [ 3 ] ;
if ( argc > = 5 ) {
if ( ! NT_STATUS_IS_OK ( GUID_from_string ( argv [ 4 ] , & domain_guid ) ) ) {
return WERR_NOMEM ;
}
}
if ( argc > = 6 )
site_name = argv [ 5 ] ;
if ( argc > = 7 )
sscanf ( argv [ 6 ] , " %x " , & flags ) ;
2007-08-28 19:01:23 +04:00
debug_dsdcinfo_flags ( 1 , flags ) ;
2007-05-25 03:11:11 +04:00
result = rpccli_netlogon_dsr_getdcnameex2 ( cli , mem_ctx , server_name ,
client_account , mask ,
domain_name , & domain_guid ,
site_name , flags ,
& info ) ;
if ( W_ERROR_IS_OK ( result ) ) {
d_printf ( " DsGetDcNameEx2 gave \n " ) ;
display_ds_domain_controller_info ( mem_ctx , info ) ;
return WERR_OK ;
}
printf ( " rpccli_netlogon_dsr_getdcnameex2 returned %s \n " ,
dos_errstr ( result ) ) ;
2005-11-13 14:38:17 +03:00
return result ;
}
2007-05-25 03:11:11 +04:00
2005-11-22 17:10:49 +03:00
static WERROR cmd_netlogon_dsr_getsitename ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR result ;
char * sitename ;
if ( argc ! = 2 ) {
fprintf ( stderr , " Usage: %s computername \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
result = rpccli_netlogon_dsr_getsitename ( cli , mem_ctx , argv [ 1 ] , & sitename ) ;
if ( ! W_ERROR_IS_OK ( result ) ) {
printf ( " rpccli_netlogon_dsr_gesitename returned %s \n " ,
nt_errstr ( werror_to_ntstatus ( result ) ) ) ;
return result ;
}
printf ( " Computer %s is on Site: %s \n " , argv [ 1 ] , sitename ) ;
return WERR_OK ;
}
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_logon_ctrl ( 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-05-24 12:10:50 +04:00
{
2001-06-23 18:58:38 +04:00
#if 0
2001-05-24 12:10:50 +04:00
uint32 query_level = 1 ;
2001-06-23 18:58:38 +04:00
# endif
2001-09-04 14:57:29 +04:00
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
2001-05-24 12:10:50 +04:00
if ( argc > 1 ) {
2001-10-12 09:56:23 +04:00
fprintf ( stderr , " Usage: %s \n " , argv [ 0 ] ) ;
2001-09-04 14:57:29 +04:00
return NT_STATUS_OK ;
2001-05-24 12:10:50 +04:00
}
#if 0
2001-09-04 14:57:29 +04:00
result = cli_netlogon_logon_ctrl ( cli , mem_ctx , query_level ) ;
if ( ! NT_STATUS_IS_OK ( result ) ) {
2001-05-24 12:10:50 +04:00
goto done ;
}
# endif
/* Display results */
return result ;
}
2001-08-28 10:43:43 +04:00
/* Display sam synchronisation information */
static void display_sam_sync ( uint32 num_deltas , SAM_DELTA_HDR * hdr_deltas ,
SAM_DELTA_CTR * deltas )
{
fstring name ;
uint32 i , j ;
for ( i = 0 ; i < num_deltas ; i + + ) {
switch ( hdr_deltas [ i ] . type ) {
case SAM_DELTA_DOMAIN_INFO :
unistr2_to_ascii ( name ,
& deltas [ i ] . domain_info . uni_dom_name ,
2007-09-21 18:37:35 +04:00
sizeof ( name ) ) ;
2001-10-12 09:56:23 +04:00
printf ( " Domain: %s \n " , name ) ;
2001-08-28 10:43:43 +04:00
break ;
case SAM_DELTA_GROUP_INFO :
unistr2_to_ascii ( name ,
& deltas [ i ] . group_info . uni_grp_name ,
2007-09-21 18:37:35 +04:00
sizeof ( name ) ) ;
2001-10-12 09:56:23 +04:00
printf ( " Group: %s \n " , name ) ;
2001-08-28 10:43:43 +04:00
break ;
case SAM_DELTA_ACCOUNT_INFO :
unistr2_to_ascii ( name ,
& deltas [ i ] . account_info . uni_acct_name ,
2007-09-21 18:37:35 +04:00
sizeof ( name ) ) ;
2001-10-12 09:56:23 +04:00
printf ( " Account: %s \n " , name ) ;
2001-08-28 10:43:43 +04:00
break ;
case SAM_DELTA_ALIAS_INFO :
unistr2_to_ascii ( name ,
& deltas [ i ] . alias_info . uni_als_name ,
2007-09-21 18:37:35 +04:00
sizeof ( name ) ) ;
2001-10-12 09:56:23 +04:00
printf ( " Alias: %s \n " , name ) ;
2001-08-28 10:43:43 +04:00
break ;
case SAM_DELTA_ALIAS_MEM : {
SAM_ALIAS_MEM_INFO * alias = & deltas [ i ] . als_mem_info ;
for ( j = 0 ; j < alias - > num_members ; j + + ) {
fstring sid_str ;
2007-12-16 00:47:30 +03:00
sid_to_fstring ( sid_str , & alias - > sids [ j ] . sid ) ;
2001-08-28 10:43:43 +04:00
2001-10-12 09:56:23 +04:00
printf ( " %s \n " , sid_str ) ;
2001-08-28 10:43:43 +04:00
}
break ;
}
case SAM_DELTA_GROUP_MEM : {
SAM_GROUP_MEM_INFO * group = & deltas [ i ] . grp_mem_info ;
for ( j = 0 ; j < group - > num_members ; j + + )
2001-10-12 09:56:23 +04:00
printf ( " rid 0x%x, attrib 0x%08x \n " ,
group - > rids [ j ] , group - > attribs [ j ] ) ;
2001-08-28 10:43:43 +04:00
break ;
}
2002-09-25 19:19:00 +04:00
case SAM_DELTA_MODIFIED_COUNT : {
SAM_DELTA_MOD_COUNT * mc = & deltas [ i ] . mod_count ;
2001-08-28 10:43:43 +04:00
2002-09-25 19:19:00 +04:00
printf ( " sam sequence update: 0x%04x \n " , mc - > seqnum ) ;
2001-08-28 10:43:43 +04:00
break ;
}
default :
2001-10-12 09:56:23 +04:00
printf ( " unknown delta type 0x%02x \n " ,
hdr_deltas [ i ] . type ) ;
2001-08-28 10:43:43 +04:00
break ;
}
}
}
/* Perform sam synchronisation */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_sam_sync ( 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-08-28 10:43:43 +04:00
{
2001-09-04 14:57:29 +04:00
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
2001-08-28 10:43:43 +04:00
uint32 database_id = 0 , num_deltas ;
SAM_DELTA_HDR * hdr_deltas ;
SAM_DELTA_CTR * deltas ;
if ( argc > 2 ) {
2001-10-12 09:56:23 +04:00
fprintf ( stderr , " Usage: %s [database_id] \n " , argv [ 0 ] ) ;
2001-09-04 14:57:29 +04:00
return NT_STATUS_OK ;
2001-08-28 10:43:43 +04:00
}
if ( argc = = 2 )
database_id = atoi ( argv [ 1 ] ) ;
/* Synchronise sam database */
2005-09-30 21:13:37 +04:00
result = rpccli_netlogon_sam_sync ( cli , mem_ctx , database_id ,
2002-09-25 19:19:00 +04:00
0 , & num_deltas , & hdr_deltas , & deltas ) ;
2001-10-12 09:56:23 +04:00
if ( ! NT_STATUS_IS_OK ( result ) )
2001-08-28 10:43:43 +04:00
goto done ;
/* Display results */
display_sam_sync ( num_deltas , hdr_deltas , deltas ) ;
done :
return result ;
}
/* Perform sam delta synchronisation */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_sam_deltas ( 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-08-28 10:43:43 +04:00
{
2001-09-04 14:57:29 +04:00
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
2001-08-28 10:43:43 +04:00
uint32 database_id , num_deltas , tmp ;
SAM_DELTA_HDR * hdr_deltas ;
SAM_DELTA_CTR * deltas ;
2006-09-06 22:32:20 +04:00
uint64 seqnum ;
2001-08-28 10:43:43 +04:00
if ( argc ! = 3 ) {
2001-10-12 09:56:23 +04:00
fprintf ( stderr , " Usage: %s database_id seqnum \n " , argv [ 0 ] ) ;
2001-09-04 14:57:29 +04:00
return NT_STATUS_OK ;
2001-08-28 10:43:43 +04:00
}
database_id = atoi ( argv [ 1 ] ) ;
tmp = atoi ( argv [ 2 ] ) ;
2006-09-06 22:32:20 +04:00
seqnum = tmp & 0xffff ;
2001-08-28 10:43:43 +04:00
2005-09-30 21:13:37 +04:00
result = rpccli_netlogon_sam_deltas ( cli , mem_ctx , database_id ,
2001-09-04 14:57:29 +04:00
seqnum , & num_deltas ,
& hdr_deltas , & deltas ) ;
2001-10-12 09:56:23 +04:00
if ( ! NT_STATUS_IS_OK ( result ) )
2001-08-28 10:43:43 +04:00
goto done ;
/* Display results */
display_sam_sync ( num_deltas , hdr_deltas , deltas ) ;
done :
return result ;
}
2001-10-30 04:49:44 +03:00
/* Log on a domain user */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_sam_logon ( struct rpc_pipe_client * cli ,
2006-03-17 01:54:07 +03:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
2001-10-30 04:49:44 +03:00
{
2006-03-17 01:54:07 +03:00
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
int logon_type = NET_LOGON_TYPE ;
const char * username , * password ;
2002-09-25 19:19:00 +04:00
int auth_level = 2 ;
2006-03-17 01:54:07 +03:00
uint32 logon_param = 0 ;
2007-01-23 13:51:35 +03:00
const char * workstation = NULL ;
2001-10-30 04:49:44 +03:00
2006-03-17 01:54:07 +03:00
/* Check arguments */
2001-10-30 04:49:44 +03:00
2007-02-09 08:16:25 +03:00
if ( argc < 3 | | argc > 7 ) {
2007-01-23 13:51:35 +03:00
fprintf ( stderr , " Usage: samlogon <username> <password> [workstation] "
2006-03-17 01:54:07 +03:00
" [logon_type (1 or 2)] [auth level (2 or 3)] [logon_parameter] \n " ) ;
return NT_STATUS_OK ;
}
2001-10-30 04:49:44 +03:00
2006-03-17 01:54:07 +03:00
username = argv [ 1 ] ;
password = argv [ 2 ] ;
2001-10-30 04:49:44 +03:00
2007-01-23 13:51:35 +03:00
if ( argc > = 4 )
workstation = argv [ 3 ] ;
2001-10-30 04:49:44 +03:00
2004-07-26 14:08:03 +04:00
if ( argc > = 5 )
2007-01-23 13:51:35 +03:00
sscanf ( argv [ 4 ] , " %i " , & logon_type ) ;
2002-09-25 19:19:00 +04:00
2007-01-23 13:51:35 +03:00
if ( argc > = 6 )
sscanf ( argv [ 5 ] , " %i " , & auth_level ) ;
if ( argc = = 7 )
sscanf ( argv [ 6 ] , " %x " , & logon_param ) ;
2002-09-25 19:19:00 +04:00
2006-03-17 01:54:07 +03:00
/* Perform the sam logon */
2001-10-30 04:49:44 +03:00
2007-01-23 13:51:35 +03:00
result = rpccli_netlogon_sam_logon ( cli , mem_ctx , logon_param , lp_workgroup ( ) , username , password , workstation , logon_type ) ;
2003-05-08 12:02:52 +04:00
2001-10-30 04:49:44 +03:00
if ( ! NT_STATUS_IS_OK ( result ) )
goto done ;
done :
2006-03-17 01:54:07 +03:00
return result ;
2001-10-30 04:49:44 +03:00
}
2003-08-20 00:39:32 +04:00
/* Change the trust account password */
2005-09-30 21:13:37 +04:00
static NTSTATUS cmd_netlogon_change_trust_pw ( struct rpc_pipe_client * cli ,
2003-08-20 00:39:32 +04:00
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL ;
/* Check arguments */
if ( argc > 1 ) {
fprintf ( stderr , " Usage: change_trust_pw " ) ;
return NT_STATUS_OK ;
}
/* Perform the sam logon */
result = trust_pw_find_change_and_store_it ( cli , mem_ctx ,
lp_workgroup ( ) ) ;
if ( ! NT_STATUS_IS_OK ( result ) )
goto done ;
done :
return result ;
}
2008-01-25 01:38:43 +03:00
static WERROR cmd_netlogon_gettrustrid ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL ;
WERROR werr = WERR_GENERAL_FAILURE ;
const char * server_name = cli - > cli - > desthost ;
const char * domain_name = lp_workgroup ( ) ;
uint32_t rid = 0 ;
if ( argc < 1 | | argc > 3 ) {
fprintf ( stderr , " Usage: %s <server_name> <domain_name> \n " ,
argv [ 0 ] ) ;
return WERR_OK ;
}
if ( argc > = 2 ) {
server_name = argv [ 1 ] ;
}
if ( argc > = 3 ) {
domain_name = argv [ 2 ] ;
}
status = rpccli_netr_LogonGetTrustRid ( cli , mem_ctx ,
server_name ,
domain_name ,
& rid ,
& werr ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( W_ERROR_IS_OK ( werr ) ) {
printf ( " Rid: %d \n " , rid ) ;
}
done :
return werr ;
}
2008-01-25 18:35:09 +03:00
static WERROR cmd_netlogon_dsr_enumtrustdom ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
NTSTATUS status = NT_STATUS_UNSUCCESSFUL ;
WERROR werr = WERR_GENERAL_FAILURE ;
const char * server_name = cli - > cli - > desthost ;
uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST ;
struct netr_DomainTrustList trusts ;
if ( argc < 1 | | argc > 3 ) {
fprintf ( stderr , " Usage: %s <server_name> <trust_flags> \n " ,
argv [ 0 ] ) ;
return WERR_OK ;
}
if ( argc > = 2 ) {
server_name = argv [ 1 ] ;
}
if ( argc > = 3 ) {
sscanf ( argv [ 2 ] , " %x " , & trust_flags ) ;
}
status = rpccli_netr_DsrEnumerateDomainTrusts ( cli , mem_ctx ,
server_name ,
trust_flags ,
& trusts ,
& werr ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( W_ERROR_IS_OK ( werr ) ) {
int i ;
printf ( " %d domains returned \n " , trusts . count ) ;
for ( i = 0 ; i < trusts . count ; i + + ) {
printf ( " %s (%s) \n " ,
trusts . array [ i ] . dns_name ,
trusts . array [ i ] . netbios_name ) ;
}
}
done :
return werr ;
}
2008-01-25 01:38:43 +03:00
2003-08-20 00:39:32 +04:00
2001-05-24 04:20:32 +04:00
/* List of commands exported by this module */
1999-03-12 08:47:06 +03:00
2001-05-24 04:20:32 +04:00
struct cmd_set netlogon_commands [ ] = {
2001-07-20 08:38:58 +04:00
{ " NETLOGON " } ,
2005-09-30 21:13:37 +04:00
{ " logonctrl2 " , RPC_RTYPE_NTSTATUS , cmd_netlogon_logon_ctrl2 , NULL , PI_NETLOGON , NULL , " Logon Control 2 " , " " } ,
2006-10-07 09:26:21 +04:00
{ " getanydcname " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_getanydcname , PI_NETLOGON , NULL , " Get trusted DC name " , " " } ,
2007-06-08 14:29:46 +04:00
{ " getdcname " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_getdcname , PI_NETLOGON , NULL , " Get trusted PDC name " , " " } ,
2005-11-13 14:38:17 +03:00
{ " dsr_getdcname " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_dsr_getdcname , PI_NETLOGON , NULL , " Get trusted DC name " , " " } ,
2007-05-25 03:11:11 +04:00
{ " dsr_getdcnameex " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_dsr_getdcnameex , PI_NETLOGON , NULL , " Get trusted DC name " , " " } ,
{ " dsr_getdcnameex2 " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_dsr_getdcnameex2 , PI_NETLOGON , NULL , " Get trusted DC name " , " " } ,
2005-11-22 17:10:49 +03:00
{ " dsr_getsitename " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_dsr_getsitename , PI_NETLOGON , NULL , " Get sitename " , " " } ,
2005-09-30 21:13:37 +04:00
{ " logonctrl " , RPC_RTYPE_NTSTATUS , cmd_netlogon_logon_ctrl , NULL , PI_NETLOGON , NULL , " Logon Control " , " " } ,
{ " samsync " , RPC_RTYPE_NTSTATUS , cmd_netlogon_sam_sync , NULL , PI_NETLOGON , NULL , " Sam Synchronisation " , " " } ,
{ " samdeltas " , RPC_RTYPE_NTSTATUS , cmd_netlogon_sam_deltas , NULL , PI_NETLOGON , NULL , " Query Sam Deltas " , " " } ,
{ " samlogon " , RPC_RTYPE_NTSTATUS , cmd_netlogon_sam_logon , NULL , PI_NETLOGON , NULL , " Sam Logon " , " " } ,
{ " change_trust_pw " , RPC_RTYPE_NTSTATUS , cmd_netlogon_change_trust_pw , NULL , PI_NETLOGON , NULL , " Change Trust Account Password " , " " } ,
2008-01-25 01:38:43 +03:00
{ " gettrustrid " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_gettrustrid , PI_NETLOGON , NULL , " Get trust rid " , " " } ,
2008-01-25 18:35:09 +03:00
{ " dsr_enumtrustdom " , RPC_RTYPE_WERROR , NULL , cmd_netlogon_dsr_enumtrustdom , PI_NETLOGON , NULL , " Enumerate trusted domains " , " " } ,
2001-07-20 08:38:58 +04:00
{ NULL }
2001-05-24 04:20:32 +04:00
} ;