2004-07-13 18:05:02 +00:00
/*
Unix SMB / CIFS implementation .
DRSUapi tests
Copyright ( C ) Andrew Tridgell 2003
Copyright ( C ) Stefan ( metze ) Metzmacher 2004
2005-10-07 08:12:05 +00:00
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2005
2005-08-30 03:37:14 +00:00
2005-10-07 08:12:05 +00: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
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 .
*/
2005-09-02 03:19:27 +00:00
2005-10-07 08:12:05 +00:00
# include "includes.h"
# include "librpc/gen_ndr/ndr_drsuapi.h"
2005-10-07 09:19:59 +00:00
# include "torture/rpc/drsuapi.h"
2005-09-02 03:19:27 +00:00
2005-10-07 09:19:59 +00:00
BOOL test_DsBind ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
2005-10-07 08:12:05 +00:00
{
NTSTATUS status ;
struct drsuapi_DsBind r ;
BOOL ret = True ;
2005-09-02 03:19:27 +00:00
2005-10-07 08:12:05 +00:00
GUID_from_string ( DRSUAPI_DS_BIND_GUID , & priv - > bind_guid ) ;
2005-09-02 03:19:27 +00:00
2005-10-07 08:12:05 +00:00
r . in . bind_guid = & priv - > bind_guid ;
r . in . bind_info = NULL ;
r . out . bind_handle = & priv - > bind_handle ;
2005-09-01 02:23:38 +00:00
2005-10-07 08:12:05 +00:00
printf ( " testing DsBind \n " ) ;
2005-09-01 02:23:38 +00:00
2005-10-07 08:12:05 +00:00
status = dcerpc_drsuapi_DsBind ( p , mem_ctx , & r ) ;
2005-09-01 02:23:38 +00:00
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 ) ;
}
2005-10-07 08:12:05 +00:00
printf ( " dcerpc_drsuapi_DsBind failed - %s \n " , errstr ) ;
2005-09-01 02:23:38 +00:00
ret = False ;
} else if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
2005-10-07 08:12:05 +00:00
printf ( " DsBind failed - %s \n " , win_errstr ( r . out . result ) ) ;
2005-09-01 02:23:38 +00:00
ret = False ;
}
2004-10-13 14:25:44 +00:00
return ret ;
}
2004-10-15 09:48:40 +00:00
static BOOL test_DsGetDCInfo ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
2004-11-03 16:02:32 +00:00
struct DsPrivate * priv )
2004-10-15 09:48:40 +00:00
{
NTSTATUS status ;
struct drsuapi_DsGetDomainControllerInfo r ;
BOOL ret = True ;
2004-11-03 16:02:32 +00:00
r . in . bind_handle = & priv - > bind_handle ;
2004-10-15 09:48:40 +00:00
r . in . level = 1 ;
2004-10-15 11:08:14 +00:00
2004-10-15 09:48:40 +00:00
r . in . req . req1 . domain_name = talloc_strdup ( mem_ctx , lp_realm ( ) ) ;
r . in . req . req1 . level = 1 ;
2004-10-15 11:08:14 +00:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 09:48:40 +00: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 11:08:14 +00: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 09:48:40 +00:00
ret = False ;
}
r . in . req . req1 . level = 2 ;
2004-10-15 11:08:14 +00:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 09:48:40 +00: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 11:08:14 +00: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 09:48:40 +00:00
ret = False ;
2004-11-03 16:02:32 +00:00
} else {
if ( r . out . ctr . ctr2 . count > 0 ) {
2004-11-22 17:30:32 +00:00
priv - > dcinfo = r . out . ctr . ctr2 . array [ 0 ] ;
2004-11-03 16:02:32 +00:00
}
2004-10-15 09:48:40 +00:00
}
r . in . req . req1 . level = - 1 ;
2004-10-15 11:08:14 +00:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 09:48:40 +00: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 11:08:14 +00: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 09:48:40 +00:00
ret = False ;
}
r . in . req . req1 . domain_name = talloc_strdup ( mem_ctx , lp_workgroup ( ) ) ;
r . in . req . req1 . level = 2 ;
2004-10-15 11:08:14 +00:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 09:48:40 +00: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 11:08:14 +00: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 09:48:40 +00:00
ret = False ;
}
r . in . req . req1 . domain_name = " __UNKNOWN_DOMAIN__ " ;
r . in . req . req1 . level = 2 ;
2004-10-15 11:08:14 +00:00
printf ( " testing DsGetDomainControllerInfo level %d on domainname '%s' \n " ,
r . in . req . req1 . level , r . in . req . req1 . domain_name ) ;
2004-10-15 09:48:40 +00: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 11:08:14 +00: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 09:48:40 +00:00
}
return ret ;
}
2004-11-23 08:57:42 +00: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 12:20:28 +00: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 06:16:59 +00:00
int32_t level ;
int32_t infotype ;
2004-12-07 12:20:28 +00: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 10:29:44 +00: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 14:42:09 +00:00
struct drsuapi_DsReplicaObjectIdentifier nc ;
struct GUID null_guid ;
struct dom_sid null_sid ;
2004-12-13 10:29:44 +00:00
struct {
2005-01-27 06:16:59 +00:00
int32_t level ;
2004-12-13 10:29:44 +00:00
} array [ ] = {
{
1
}
} ;
2004-12-31 01:02:22 +00:00
if ( ! lp_parm_bool ( - 1 , " torture " , " dangerous " , False ) ) {
2004-12-13 12:28:47 +00:00
printf ( " DsReplicaSync disabled - enable dangerous tests to use \n " ) ;
return True ;
}
2005-03-15 14:42:09 +00:00
ZERO_STRUCT ( null_guid ) ;
ZERO_STRUCT ( null_sid ) ;
2004-12-13 10:29:44 +00:00
r . in . bind_handle = & priv - > bind_handle ;
for ( i = 0 ; i < ARRAY_SIZE ( array ) ; i + + ) {
2005-03-11 12:15:50 +00:00
printf ( " testing DsReplicaSync level %d \n " ,
2004-12-13 10:29:44 +00:00
array [ i ] . level ) ;
r . in . level = array [ i ] . level ;
switch ( r . in . level ) {
2004-12-13 11:34:57 +00:00
case 1 :
2005-03-15 14:42:09 +00: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 10:29:44 +00:00
r . in . req . req1 . guid1 = priv - > dcinfo . ntds_guid ;
r . in . req . req1 . string1 = NULL ;
2005-03-11 12:15:50 +00:00
r . in . req . req1 . options = 16 ;
2004-12-13 10:29:44 +00: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 12:15:50 +00: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 14:42:09 +00:00
struct drsuapi_DsReplicaObjectIdentifier nc ;
2005-03-11 12:15:50 +00:00
struct GUID null_guid ;
2005-03-15 14:42:09 +00:00
struct dom_sid null_sid ;
2005-03-11 12:15:50 +00:00
struct {
int32_t level ;
} array [ ] = {
{
1
}
} ;
ZERO_STRUCT ( null_guid ) ;
2005-03-15 14:42:09 +00:00
ZERO_STRUCT ( null_sid ) ;
2005-03-11 12:15:50 +00: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 14:42:09 +00: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 12:15:50 +00:00
priv - > domain_dns_name ) ;
2005-03-15 14:42:09 +00:00
r . in . req . req1 . dest_dsa_guid = null_guid ;
r . in . req . req1 . options = 0 ;
2005-03-11 12:15:50 +00: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 14:42:09 +00: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 18:54:06 +00:00
2005-03-15 14:42:09 +00: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 14:49:11 +00: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 18:55:12 +00:00
r . in . req . req5 . highwatermark . tmp_highest_usn = 0 ;
2005-03-23 18:54:06 +00: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 06:19:44 +00: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 18:54:06 +00:00
r . in . req . req5 . unknown2 = 0 ;
r . in . req . req5 . unknown3 = 0 ;
2005-03-22 14:49:11 +00:00
r . in . req . req5 . unknown4 = 0 ;
r . in . req . req5 . h1 = 0 ;
2005-03-16 15:47:19 +00:00
2005-03-15 14:42:09 +00:00
break ;
case 8 :
2005-03-22 14:49:11 +00: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 18:54:06 +00: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 14:49:11 +00: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 15:47:19 +00:00
2005-03-15 14:42:09 +00: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 ;
}
2005-10-07 09:19:59 +00:00
BOOL test_DsUnbind ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx ,
struct DsPrivate * priv )
2004-07-13 18:05:02 +00:00
{
NTSTATUS status ;
2004-10-10 01:30:54 +00:00
struct drsuapi_DsUnbind r ;
2004-07-13 18:05:02 +00:00
BOOL ret = True ;
2004-11-03 16:02:32 +00:00
r . in . bind_handle = & priv - > bind_handle ;
r . out . bind_handle = & priv - > bind_handle ;
2004-07-13 18:05:02 +00:00
2004-10-15 11:08:14 +00:00
printf ( " testing DsUnbind \n " ) ;
2004-10-10 01:30:54 +00:00
status = dcerpc_drsuapi_DsUnbind ( p , mem_ctx , & r ) ;
2004-07-13 18:05:02 +00:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2004-08-20 15:00:22 +00:00
const char * errstr = nt_errstr ( status ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_NET_WRITE_FAULT ) ) {
2004-08-30 03:10:43 +00:00
errstr = dcerpc_errstr ( mem_ctx , p - > last_fault_code ) ;
2004-08-20 15:00:22 +00:00
}
2004-10-15 11:08:14 +00: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 18:05:02 +00:00
ret = False ;
}
return ret ;
}
2004-10-28 13:40:50 +00:00
BOOL torture_rpc_drsuapi ( void )
2004-07-13 18:05:02 +00:00
{
NTSTATUS status ;
struct dcerpc_pipe * p ;
TALLOC_CTX * mem_ctx ;
BOOL ret = True ;
2004-11-03 16:02:32 +00:00
struct DsPrivate priv ;
2004-08-04 09:33:41 +00:00
2005-03-22 08:00:45 +00:00
mem_ctx = talloc_init ( " torture_rpc_drsuapi " ) ;
status = torture_rpc_connection ( mem_ctx ,
& p ,
2004-09-17 10:44:28 +00:00
DCERPC_DRSUAPI_NAME ,
DCERPC_DRSUAPI_UUID ,
DCERPC_DRSUAPI_VERSION ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-03-22 08:00:45 +00:00
talloc_free ( mem_ctx ) ;
2004-08-04 09:33:41 +00:00
return False ;
}
2004-07-13 18:05:02 +00:00
2004-09-17 10:44:28 +00:00
printf ( " Connected to DRAUAPI pipe \n " ) ;
2004-08-04 09:33:41 +00:00
2004-11-22 17:30:32 +00:00
ZERO_STRUCT ( priv ) ;
2004-12-13 12:24:57 +00:00
ret & = test_DsBind ( p , mem_ctx , & priv ) ;
2004-07-13 18:05:02 +00:00
2004-12-13 12:24:57 +00:00
ret & = test_DsGetDCInfo ( p , mem_ctx , & priv ) ;
2004-10-15 09:48:40 +00:00
2005-09-02 03:19:27 +00:00
ret & = test_DsCrackNames ( p , mem_ctx , & priv , priv . dcinfo . netbios_name ) ;
2004-10-13 14:25:44 +00:00
2004-12-13 12:24:57 +00:00
ret & = test_DsWriteAccountSpn ( p , mem_ctx , & priv ) ;
2004-11-23 08:57:42 +00:00
2004-12-13 12:24:57 +00:00
ret & = test_DsReplicaGetInfo ( p , mem_ctx , & priv ) ;
2004-12-07 12:20:28 +00:00
2004-12-13 12:28:47 +00:00
ret & = test_DsReplicaSync ( p , mem_ctx , & priv ) ;
2004-12-13 10:29:44 +00:00
2005-03-11 12:15:50 +00:00
ret & = test_DsReplicaUpdateRefs ( p , mem_ctx , & priv ) ;
2005-03-15 14:42:09 +00:00
ret & = test_DsGetNCChanges ( p , mem_ctx , & priv ) ;
2004-12-13 12:24:57 +00:00
ret & = test_DsUnbind ( p , mem_ctx , & priv ) ;
2004-07-13 18:05:02 +00:00
2005-01-27 07:08:20 +00:00
talloc_free ( mem_ctx ) ;
2004-07-13 18:05:02 +00:00
return ret ;
}
2005-08-29 04:15:08 +00:00