2004-07-13 22:05:02 +04:00
/*
Unix SMB / CIFS implementation .
DRSUapi tests
Copyright ( C ) Andrew Tridgell 2003
Copyright ( C ) Stefan ( metze ) Metzmacher 2004
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
the Free Software Foundation ; either version 2 of the License , or
( 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
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2004-11-01 13:30:34 +03:00
# include "librpc/gen_ndr/ndr_drsuapi.h"
2004-07-13 22:05:02 +04:00
2004-11-03 19:02:32 +03:00
struct DsPrivate {
struct policy_handle bind_handle ;
2004-11-23 11:57:42 +03:00
struct GUID bind_guid ;
2004-12-07 15:20:28 +03:00
const char * domain_obj_dn ;
2004-11-22 20:30:32 +03:00
const char * domain_guid_str ;
2005-03-11 15:15:50 +03:00
const char * domain_dns_name ;
2004-12-07 15:20:28 +03:00
struct GUID domain_guid ;
2004-11-22 20:30:32 +03:00
struct drsuapi_DsGetDCInfo2 dcinfo ;
2004-11-03 19:02:32 +03:00
} ;
2004-10-10 05:30:54 +04:00
static BOOL test_DsBind ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2004-11-03 19:02:32 +03:00
struct DsPrivate * priv )
2004-07-13 22:05:02 +04:00
{
NTSTATUS status ;
2004-10-10 05:30:54 +04:00
struct drsuapi_DsBind r ;
2004-09-17 14:44:28 +04:00
BOOL ret = True ;
2004-07-13 22:05:02 +04:00
2004-11-23 11:57:42 +03:00
GUID_from_string ( DRSUAPI_DS_BIND_GUID , & priv - > bind_guid ) ;
r . in . bind_guid = & priv - > bind_guid ;
2004-10-14 14:16:22 +04:00
r . in . bind_info = NULL ;
2004-11-03 19:02:32 +03:00
r . out . bind_handle = & priv - > bind_handle ;
2004-07-13 22:05:02 +04:00
2004-10-15 15:08:14 +04:00
printf ( " testing DsBind \n " ) ;
2004-10-10 05:30:54 +04:00
status = dcerpc_drsuapi_DsBind ( p , mem_ctx , & r ) ;
2004-07-13 22:05:02 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2004-09-17 14:44:28 +04:00
const char * errstr = nt_errstr ( status ) ;
2004-07-13 22:05:02 +04:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
2004-09-17 14:44:28 +04:00
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
2004-07-13 22:05:02 +04:00
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsBind failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsBind failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-09-17 14:44:28 +04:00
ret = False ;
2004-07-13 22:05:02 +04:00
}
2004-09-17 14:44:28 +04:00
return ret ;
2004-07-13 22:05:02 +04:00
}
2004-10-13 18:25:44 +04:00
static BOOL test_DsCrackNames ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2004-11-03 19:02:32 +03:00
struct DsPrivate * priv )
2004-10-13 18:25:44 +04:00
{
NTSTATUS status ;
struct drsuapi_DsCrackNames r ;
2004-10-14 13:56:04 +04:00
struct drsuapi_DsNameString names [ 1 ] ;
2004-10-13 18:25:44 +04:00
BOOL ret = True ;
2004-10-14 13:56:04 +04:00
const char * dns_domain ;
const char * nt4_domain ;
const char * FQDN_1779_name ;
2004-10-13 18:25:44 +04:00
ZERO_STRUCT ( r ) ;
2004-11-03 19:02:32 +03:00
r . in . bind_handle = & priv - > bind_handle ;
2004-10-14 13:56:04 +04:00
r . in . level = 1 ;
r . in . req . req1 . unknown1 = 0x000004e4 ;
r . in . req . req1 . unknown2 = 0x00000407 ;
r . in . req . req1 . count = 1 ;
r . in . req . req1 . names = names ;
r . in . req . req1 . format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS ;
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_CANONICAL ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ;
2004-10-13 18:25:44 +04:00
names [ 0 ] . str = talloc_asprintf ( mem_ctx , " %s/ " , lp_realm ( ) ) ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-13 18:25:44 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-13 18:25:44 +04:00
ret = False ;
}
2004-10-14 13:56:04 +04:00
if ( ! ret ) {
return ret ;
}
dns_domain = r . out . ctr . ctr1 - > array [ 0 ] . dns_domain_name ;
nt4_domain = r . out . ctr . ctr1 - > array [ 0 ] . result_name ;
2004-11-22 20:30:32 +03:00
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_GUID ;
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2005-03-11 15:15:50 +03:00
priv - > domain_dns_name = r . out . ctr . ctr1 - > array [ 0 ] . dns_domain_name ;
2004-11-22 20:30:32 +03:00
priv - > domain_guid_str = r . out . ctr . ctr1 - > array [ 0 ] . result_name ;
2004-12-07 15:20:28 +03:00
GUID_from_string ( priv - > domain_guid_str , & priv - > domain_guid ) ;
2004-11-22 20:30:32 +03:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_GUID ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ;
names [ 0 ] . str = priv - > domain_guid_str ;
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-10-14 13:56:04 +04:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
names [ 0 ] . str = nt4_domain ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-12-07 15:20:28 +03:00
priv - > domain_obj_dn = r . out . ctr . ctr1 - > array [ 0 ] . result_name ;
2004-10-14 13:56:04 +04:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
2004-11-22 20:30:32 +03:00
names [ 0 ] . str = talloc_asprintf ( mem_ctx , " %s%s$ " , nt4_domain , priv - > dcinfo . netbios_name ) ;
2004-10-14 13:56:04 +04:00
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
FQDN_1779_name = r . out . ctr . ctr1 - > array [ 0 ] . result_name ;
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL ;
names [ 0 ] . str = FQDN_1779_name ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_GUID ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsCrackNames with name '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
2004-10-14 13:56:04 +04:00
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-10-14 13:56:04 +04:00
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-11-03 19:02:32 +03:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_GUID ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
2004-11-22 20:30:32 +03:00
names [ 0 ] . str = GUID_string2 ( mem_ctx , & priv - > dcinfo . site_guid ) ;
2004-11-03 19:02:32 +03:00
printf ( " testing DsCrackNames with Site GUID '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-11-22 20:30:32 +03:00
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT ;
names [ 0 ] . str = GUID_string2 ( mem_ctx , & priv - > dcinfo . computer_guid ) ;
2004-11-03 19:02:32 +03:00
printf ( " testing DsCrackNames with Computer GUID '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-11-23 11:57:42 +03:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_GUID ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
2004-11-22 20:30:32 +03:00
names [ 0 ] . str = GUID_string2 ( mem_ctx , & priv - > dcinfo . server_guid ) ;
2004-11-03 19:02:32 +03:00
printf ( " testing DsCrackNames with Server GUID '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-11-23 11:57:42 +03:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_GUID ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
2004-11-22 20:30:32 +03:00
names [ 0 ] . str = GUID_string2 ( mem_ctx , & priv - > dcinfo . ntds_guid ) ;
2004-11-03 19:02:32 +03:00
printf ( " testing DsCrackNames with NTDS GUID '%s' desired format:%d \n " ,
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-11-23 11:57:42 +03:00
r . in . req . req1 . format_offered = DRSUAPI_DS_NAME_FORMAT_GUID ;
r . in . req . req1 . format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779 ;
names [ 0 ] . str = GUID_string2 ( mem_ctx , & priv - > bind_guid ) ;
2004-12-07 15:20:28 +03:00
printf ( " testing DsCrackNames with BIND GUID '%s' desired format:%d \n " ,
2004-11-23 11:57:42 +03:00
names [ 0 ] . str , r . in . req . req1 . format_desired ) ;
status = dcerpc_drsuapi_DsCrackNames ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsCrackNames failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsCrackNames failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
if ( ! ret ) {
return ret ;
}
2004-10-13 18:25:44 +04:00
return ret ;
}
2004-10-15 13:48:40 +04:00
static BOOL test_DsGetDCInfo ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2004-11-03 19:02:32 +03:00
struct DsPrivate * priv )
2004-10-15 13:48:40 +04:00
{
NTSTATUS status ;
struct drsuapi_DsGetDomainControllerInfo r ;
BOOL ret = True ;
2004-11-03 19:02:32 +03:00
r . in . bind_handle = & priv - > bind_handle ;
2004-10-15 13:48:40 +04:00
r . in . level = 1 ;
2004-10-15 15:08:14 +04:00
2004-10-15 13:48:40 +04:00
r . in . req . req1 . domain_name = talloc_strdup ( mem_ctx , lp_realm ( ) ) ;
r . in . req . req1 . level = 1 ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 13:48:40 +04:00
status = dcerpc_drsuapi_DsGetDomainControllerInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , win_errstr ( r . out . result ) ) ;
2004-10-15 13:48:40 +04:00
ret = False ;
}
r . in . req . req1 . level = 2 ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 13:48:40 +04:00
status = dcerpc_drsuapi_DsGetDomainControllerInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , win_errstr ( r . out . result ) ) ;
2004-10-15 13:48:40 +04:00
ret = False ;
2004-11-03 19:02:32 +03:00
} else {
if ( r . out . ctr . ctr2 . count > 0 ) {
2004-11-22 20:30:32 +03:00
priv - > dcinfo = r . out . ctr . ctr2 . array [ 0 ] ;
2004-11-03 19:02:32 +03:00
}
2004-10-15 13:48:40 +04:00
}
r . in . req . req1 . level = - 1 ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 13:48:40 +04:00
status = dcerpc_drsuapi_DsGetDomainControllerInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsGetDomainControllerInfo level %d \n "
" with dns domain failed - %s \n " ,
r . in . req . req1 . level , win_errstr ( r . out . result ) ) ;
2004-10-15 13:48:40 +04:00
ret = False ;
}
r . in . req . req1 . domain_name = talloc_strdup ( mem_ctx , lp_workgroup ( ) ) ;
r . in . req . req1 . level = 2 ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 13:48:40 +04:00
status = dcerpc_drsuapi_DsGetDomainControllerInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsGetDomainControllerInfo level %d \n "
" with netbios domain failed - %s \n " ,
r . in . req . req1 . level , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsGetDomainControllerInfo level %d \n "
" with netbios domain failed - %s \n " ,
r . in . req . req1 . level , win_errstr ( r . out . result ) ) ;
2004-10-15 13:48:40 +04:00
ret = False ;
}
r . in . req . req1 . domain_name = " __UNKNOWN_DOMAIN__ " ;
r . in . req . req1 . level = 2 ;
2004-10-15 15:08:14 +04:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 13:48:40 +04:00
status = dcerpc_drsuapi_DsGetDomainControllerInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsGetDomainControllerInfo level %d \n "
" with invalid domain failed - %s \n " ,
r . in . req . req1 . level , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_EQUAL ( r . out . result , WERR_DS_OBJ_NOT_FOUND ) ) {
printf ( " DsGetDomainControllerInfo level %d \n "
" with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s \n " ,
r . in . req . req1 . level , win_errstr ( r . out . result ) ) ;
ret = False ;
2004-10-15 13:48:40 +04:00
}
return ret ;
}
2004-11-23 11:57:42 +03:00
static BOOL test_DsWriteAccountSpn ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
{
NTSTATUS status ;
struct drsuapi_DsWriteAccountSpn r ;
struct drsuapi_DsNameString names [ 2 ] ;
BOOL ret = True ;
r . in . bind_handle = & priv - > bind_handle ;
r . in . level = 1 ;
printf ( " testing DsWriteAccountSpn \n " ) ;
r . in . req . req1 . operation = DRSUAPI_DS_SPN_OPERATION_ADD ;
r . in . req . req1 . unknown1 = 0 ;
r . in . req . req1 . object_dn = priv - > dcinfo . computer_dn ;
r . in . req . req1 . count = 2 ;
r . in . req . req1 . spn_names = names ;
names [ 0 ] . str = talloc_asprintf ( mem_ctx , " smbtortureSPN/%s " , priv - > dcinfo . netbios_name ) ;
names [ 1 ] . str = talloc_asprintf ( mem_ctx , " smbtortureSPN/%s " , priv - > dcinfo . dns_name ) ;
status = dcerpc_drsuapi_DsWriteAccountSpn ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsWriteAccountSpn failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsWriteAccountSpn failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
r . in . req . req1 . operation = DRSUAPI_DS_SPN_OPERATION_DELETE ;
r . in . req . req1 . unknown1 = 0 ;
status = dcerpc_drsuapi_DsWriteAccountSpn ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsWriteAccountSpn failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsWriteAccountSpn failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
return ret ;
}
2004-12-07 15:20:28 +03:00
static BOOL test_DsReplicaGetInfo ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
{
NTSTATUS status ;
struct drsuapi_DsReplicaGetInfo r ;
BOOL ret = True ;
int i ;
struct {
2005-01-27 09:16:59 +03:00
int32_t level ;
int32_t infotype ;
2004-12-07 15:20:28 +03:00
const char * obj_dn ;
} array [ ] = {
{
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_NEIGHBORS ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_CURSORS ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO ,
DRSUAPI_DS_REPLICA_INFO_PENDING_OPS ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_CURSORS2 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_CURSORS3 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04 ,
" __IGNORED__ "
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_CURSURS05 ,
NULL
} , {
DRSUAPI_DS_REPLICA_GET_INFO2 ,
DRSUAPI_DS_REPLICA_INFO_06 ,
NULL
}
} ;
r . in . bind_handle = & priv - > bind_handle ;
for ( i = 0 ; i < ARRAY_SIZE ( array ) ; i + + ) {
const char * object_dn ;
printf ( " testing DsReplicaGetInfo level %d infotype %d \n " ,
array [ i ] . level , array [ i ] . infotype ) ;
object_dn = ( array [ i ] . obj_dn ? array [ i ] . obj_dn : priv - > domain_obj_dn ) ;
r . in . level = array [ i ] . level ;
switch ( r . in . level ) {
case DRSUAPI_DS_REPLICA_GET_INFO :
r . in . req . req1 . info_type = array [ i ] . infotype ;
r . in . req . req1 . object_dn = object_dn ;
ZERO_STRUCT ( r . in . req . req1 . guid1 ) ;
break ;
case DRSUAPI_DS_REPLICA_GET_INFO2 :
r . in . req . req2 . info_type = array [ i ] . infotype ;
r . in . req . req2 . object_dn = object_dn ;
ZERO_STRUCT ( r . in . req . req1 . guid1 ) ;
r . in . req . req2 . unknown1 = 0 ;
r . in . req . req2 . string1 = NULL ;
r . in . req . req2 . string2 = NULL ;
r . in . req . req2 . unknown2 = 0 ;
break ;
}
status = dcerpc_drsuapi_DsReplicaGetInfo ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
if ( p - > last_fault_code ! = DCERPC_FAULT_INVALID_TAG ) {
printf ( " dcerpc_drsuapi_DsReplicaGetInfo failed - %s \n " , errstr ) ;
ret = False ;
} else {
printf ( " DsReplicaGetInfo level %d and/or infotype %d not supported by server \n " ,
array [ i ] . level , array [ i ] . infotype ) ;
}
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsReplicaGetInfo failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
}
return ret ;
}
2004-12-13 13:29:44 +03:00
static BOOL test_DsReplicaSync ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
{
NTSTATUS status ;
BOOL ret = True ;
int i ;
struct drsuapi_DsReplicaSync r ;
2005-03-15 17:42:09 +03:00
struct drsuapi_DsReplicaObjectIdentifier nc ;
struct GUID null_guid ;
struct dom_sid null_sid ;
2004-12-13 13:29:44 +03:00
struct {
2005-01-27 09:16:59 +03:00
int32_t level ;
2004-12-13 13:29:44 +03:00
} array [ ] = {
{
1
}
} ;
2004-12-31 04:02:22 +03:00
if ( ! lp_parm_bool ( - 1 , " torture " , " dangerous " , False ) ) {
2004-12-13 15:28:47 +03:00
printf ( " DsReplicaSync disabled - enable dangerous tests to use \n " ) ;
return True ;
}
2005-03-15 17:42:09 +03:00
ZERO_STRUCT ( null_guid ) ;
ZERO_STRUCT ( null_sid ) ;
2004-12-13 13:29:44 +03:00
r . in . bind_handle = & priv - > bind_handle ;
for ( i = 0 ; i < ARRAY_SIZE ( array ) ; i + + ) {
2005-03-11 15:15:50 +03:00
printf ( " testing DsReplicaSync level %d \n " ,
2004-12-13 13:29:44 +03:00
array [ i ] . level ) ;
r . in . level = array [ i ] . level ;
switch ( r . in . level ) {
2004-12-13 14:34:57 +03:00
case 1 :
2005-03-15 17:42:09 +03:00
nc . guid = null_guid ;
nc . sid = null_sid ;
nc . dn = priv - > domain_obj_dn ? priv - > domain_obj_dn : " " ;
r . in . req . req1 . naming_context = & nc ;
2004-12-13 13:29:44 +03:00
r . in . req . req1 . guid1 = priv - > dcinfo . ntds_guid ;
r . in . req . req1 . string1 = NULL ;
2005-03-11 15:15:50 +03:00
r . in . req . req1 . options = 16 ;
2004-12-13 13:29:44 +03:00
break ;
}
status = dcerpc_drsuapi_DsReplicaSync ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsReplicaSync failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsReplicaSync failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
}
return ret ;
}
2005-03-11 15:15:50 +03:00
static BOOL test_DsReplicaUpdateRefs ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
{
NTSTATUS status ;
BOOL ret = True ;
int i ;
struct drsuapi_DsReplicaUpdateRefs r ;
2005-03-15 17:42:09 +03:00
struct drsuapi_DsReplicaObjectIdentifier nc ;
2005-03-11 15:15:50 +03:00
struct GUID null_guid ;
2005-03-15 17:42:09 +03:00
struct dom_sid null_sid ;
2005-03-11 15:15:50 +03:00
struct {
int32_t level ;
} array [ ] = {
{
1
}
} ;
ZERO_STRUCT ( null_guid ) ;
2005-03-15 17:42:09 +03:00
ZERO_STRUCT ( null_sid ) ;
2005-03-11 15:15:50 +03:00
r . in . bind_handle = & priv - > bind_handle ;
for ( i = 0 ; i < ARRAY_SIZE ( array ) ; i + + ) {
printf ( " testing DsReplicaUpdateRefs level %d \n " ,
array [ i ] . level ) ;
r . in . level = array [ i ] . level ;
switch ( r . in . level ) {
case 1 :
2005-03-15 17:42:09 +03:00
nc . guid = null_guid ;
nc . sid = null_sid ;
nc . dn = priv - > domain_obj_dn ? priv - > domain_obj_dn : " " ;
r . in . req . req1 . naming_context = & nc ;
r . in . req . req1 . dest_dsa_dns_name = talloc_asprintf ( mem_ctx , " __some_dest_dsa_guid_string._msdn.%s " ,
2005-03-11 15:15:50 +03:00
priv - > domain_dns_name ) ;
2005-03-15 17:42:09 +03:00
r . in . req . req1 . dest_dsa_guid = null_guid ;
r . in . req . req1 . options = 0 ;
2005-03-11 15:15:50 +03:00
break ;
}
status = dcerpc_drsuapi_DsReplicaUpdateRefs ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsReplicaUpdateRefs failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
}
return ret ;
}
2005-03-15 17:42:09 +03:00
static BOOL test_DsGetNCChanges ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
{
NTSTATUS status ;
BOOL ret = True ;
int i ;
struct drsuapi_DsGetNCChanges r ;
struct drsuapi_DsReplicaObjectIdentifier nc ;
struct GUID null_guid ;
struct dom_sid null_sid ;
struct {
int32_t level ;
} array [ ] = {
{
5
} ,
{
8
}
} ;
ZERO_STRUCT ( null_guid ) ;
ZERO_STRUCT ( null_sid ) ;
2005-03-23 21:54:06 +03:00
2005-03-15 17:42:09 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( array ) ; i + + ) {
printf ( " testing DsGetNCChanges level %d \n " ,
array [ i ] . level ) ;
r . in . bind_handle = & priv - > bind_handle ;
r . in . level = array [ i ] . level ;
switch ( r . in . level ) {
case 5 :
2005-03-22 17:49:11 +03:00
nc . guid = null_guid ;
nc . sid = null_sid ;
nc . dn = priv - > domain_obj_dn ? priv - > domain_obj_dn : " " ;
r . in . req . req5 . destination_dsa_guid = GUID_random ( ) ;
r . in . req . req5 . source_dsa_guid = null_guid ;
r . in . req . req5 . naming_context = & nc ;
2005-03-23 21:55:12 +03:00
r . in . req . req5 . highwatermark . tmp_highest_usn = 0 ;
2005-03-23 21:54:06 +03:00
r . in . req . req5 . highwatermark . reserved_usn = 0 ;
r . in . req . req5 . highwatermark . highest_usn = 0 ;
r . in . req . req5 . uptodateness_vector = NULL ;
2005-03-29 10:19:44 +04:00
r . in . req . req5 . replica_flags = 0 ;
if ( lp_parm_bool ( - 1 , " drsuapi " , " compression " , False ) ) {
r . in . req . req5 . replica_flags | = DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES ;
}
2005-03-23 21:54:06 +03:00
r . in . req . req5 . unknown2 = 0 ;
r . in . req . req5 . unknown3 = 0 ;
2005-03-22 17:49:11 +03:00
r . in . req . req5 . unknown4 = 0 ;
r . in . req . req5 . h1 = 0 ;
2005-03-16 18:47:19 +03:00
2005-03-15 17:42:09 +03:00
break ;
case 8 :
2005-03-22 17:49:11 +03:00
nc . guid = null_guid ;
nc . sid = null_sid ;
nc . dn = priv - > domain_obj_dn ? priv - > domain_obj_dn : " " ;
r . in . req . req8 . destination_dsa_guid = GUID_random ( ) ;
r . in . req . req8 . source_dsa_guid = null_guid ;
r . in . req . req8 . naming_context = & nc ;
2005-03-23 21:54:06 +03:00
r . in . req . req8 . highwatermark . tmp_highest_usn = 0 ;
r . in . req . req8 . highwatermark . reserved_usn = 0 ;
r . in . req . req8 . highwatermark . highest_usn = 0 ;
r . in . req . req8 . uptodateness_vector = NULL ;
r . in . req . req8 . replica_flags = 0
| DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
| DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
| DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
| DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
| DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
| DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES
;
2005-03-22 17:49:11 +03:00
r . in . req . req8 . unknown2 = 402 ;
r . in . req . req8 . unknown3 = 402116 ;
r . in . req . req8 . unknown4 = 0 ;
r . in . req . req8 . h1 = 0 ;
r . in . req . req8 . unique_ptr1 = 0 ;
r . in . req . req8 . unique_ptr2 = 0 ;
r . in . req . req8 . ctr12 . count = 0 ;
r . in . req . req8 . ctr12 . array = NULL ;
2005-03-16 18:47:19 +03:00
2005-03-15 17:42:09 +03:00
break ;
}
status = dcerpc_drsuapi_DsGetNCChanges ( p , mem_ctx , & r ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
}
printf ( " dcerpc_drsuapi_DsGetNCChanges failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsGetNCChanges failed - %s \n " , win_errstr ( r . out . result ) ) ;
ret = False ;
}
}
return ret ;
}
2004-10-10 05:30:54 +04:00
static BOOL test_DsUnbind ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2004-11-03 19:02:32 +03:00
struct DsPrivate * priv )
2004-07-13 22:05:02 +04:00
{
NTSTATUS status ;
2004-10-10 05:30:54 +04:00
struct drsuapi_DsUnbind r ;
2004-07-13 22:05:02 +04:00
BOOL ret = True ;
2004-11-03 19:02:32 +03:00
r . in . bind_handle = & priv - > bind_handle ;
r . out . bind_handle = & priv - > bind_handle ;
2004-07-13 22:05:02 +04:00
2004-10-15 15:08:14 +04:00
printf ( " testing DsUnbind \n " ) ;
2004-10-10 05:30:54 +04:00
status = dcerpc_drsuapi_DsUnbind ( p , mem_ctx , & r ) ;
2004-07-13 22:05:02 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2004-08-20 19:00:22 +04:00
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
2004-08-30 07:10:43 +04:00
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
2004-08-20 19:00:22 +04:00
}
2004-10-15 15:08:14 +04:00
printf ( " dcerpc_drsuapi_DsUnbind failed - %s \n " , errstr ) ;
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
printf ( " DsBind failed - %s \n " , win_errstr ( r . out . result ) ) ;
2004-07-13 22:05:02 +04:00
ret = False ;
}
return ret ;
}
2004-10-28 17:40:50 +04:00
BOOL torture_rpc_drsuapi ( void )
2004-07-13 22:05:02 +04:00
{
NTSTATUS status ;
struct dcerpc_pipe * p ;
TALLOC_CTX * mem_ctx ;
BOOL ret = True ;
2004-11-03 19:02:32 +03:00
struct DsPrivate priv ;
2004-08-04 13:33:41 +04:00
2005-03-22 11:00:45 +03:00
mem_ctx = talloc_init ( " torture_rpc_drsuapi " ) ;
status = torture_rpc_connection ( mem_ctx ,
& p ,
2004-09-17 14:44:28 +04:00
DCERPC_DRSUAPI_NAME ,
DCERPC_DRSUAPI_UUID ,
DCERPC_DRSUAPI_VERSION ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-03-22 11:00:45 +03:00
talloc_free ( mem_ctx ) ;
2004-08-04 13:33:41 +04:00
return False ;
}
2004-07-13 22:05:02 +04:00
2004-09-17 14:44:28 +04:00
printf ( " Connected to DRAUAPI pipe \n " ) ;
2004-08-04 13:33:41 +04:00
2004-11-22 20:30:32 +03:00
ZERO_STRUCT ( priv ) ;
2004-12-13 15:24:57 +03:00
ret & = test_DsBind ( p , mem_ctx , & priv ) ;
2004-07-13 22:05:02 +04:00
2004-12-13 15:24:57 +03:00
ret & = test_DsGetDCInfo ( p , mem_ctx , & priv ) ;
2004-10-15 13:48:40 +04:00
2004-12-13 15:24:57 +03:00
ret & = test_DsCrackNames ( p , mem_ctx , & priv ) ;
2004-10-13 18:25:44 +04:00
2004-12-13 15:24:57 +03:00
ret & = test_DsWriteAccountSpn ( p , mem_ctx , & priv ) ;
2004-11-23 11:57:42 +03:00
2004-12-13 15:24:57 +03:00
ret & = test_DsReplicaGetInfo ( p , mem_ctx , & priv ) ;
2004-12-07 15:20:28 +03:00
2004-12-13 15:28:47 +03:00
ret & = test_DsReplicaSync ( p , mem_ctx , & priv ) ;
2004-12-13 13:29:44 +03:00
2005-03-11 15:15:50 +03:00
ret & = test_DsReplicaUpdateRefs ( p , mem_ctx , & priv ) ;
2005-03-15 17:42:09 +03:00
ret & = test_DsGetNCChanges ( p , mem_ctx , & priv ) ;
2004-12-13 15:24:57 +03:00
ret & = test_DsUnbind ( p , mem_ctx , & priv ) ;
2004-07-13 22:05:02 +04:00
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2004-07-13 22:05:02 +04:00
return ret ;
}