r2991: add drsuapi_DsGetDomainControllerInfo() idl and torture test
authorStefan Metzmacher <metze@samba.org>
Fri, 15 Oct 2004 09:48:40 +0000 (09:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:55 +0000 (12:59 -0500)
metze

source/librpc/idl/drsuapi.idl
source/rpc_server/drsuapi/dcesrv_drsuapi.c
source/torture/rpc/drsuapi.c

index 3705e9f029e632094784eff74d9ade28b5f55ecf..4a0cc7297e6601ff2b7d03e48f6b68c0824c2b61 100644 (file)
@@ -158,7 +158,80 @@ interface drsuapi
 
        /*****************/
         /* Function 0x10 */
-       NTSTATUS DRSUAPI_DOMAIN_CONTROLLER_INFO();
+       typedef struct {
+               unistr *domain_name; /* netbios or dns */
+               int32 level; /* specifies the switch level for the request */
+       } drsuapi_DsGetDCInfoRequest1;
+
+       typedef union {
+               [case(1)] drsuapi_DsGetDCInfoRequest1 req1;
+       } drsuapi_DsGetDCInfoRequest;
+
+       typedef struct {
+               unistr *netbios_name;
+               unistr *dns_name;
+               unistr *site_name;
+               unistr *computer_dn;
+               unistr *server_dn;
+               uint32 is_pdc;
+               uint32 is_enabled;
+       } drsuapi_DsGetDCInfo1;
+
+       typedef struct {
+               [range(0,10000)] uint32 count;
+               [size_is(count)] drsuapi_DsGetDCInfo1 *array;
+       } drsuapi_DsGetDCInfoCtr1;
+
+       typedef struct {
+               unistr *netbios_name;
+               unistr *dns_name;
+               unistr *site_name;
+               unistr *site_dn;
+               unistr *computer_dn;
+               unistr *server_dn;
+               unistr *ntds_dn;
+               uint32 is_pdc;
+               uint32 is_enabled;
+               uint32 is_gc;
+               GUID site_guid;
+               GUID computer_guid;
+               GUID server_guid;
+               GUID ntds_guid;
+       } drsuapi_DsGetDCInfo2;
+
+       typedef struct {
+               [range(0,10000)] uint32 count;
+               [size_is(count)] drsuapi_DsGetDCInfo2 *array;
+       } drsuapi_DsGetDCInfoCtr2;
+
+       typedef struct {
+               uint32 unknown1;
+               uint32 unknown2;
+               uint32 unknown3;
+               uint32 unknown4;
+               uint32 unknown5;
+               uint32 unknown6;
+               unistr *server_nt4_account;
+       } drsuapi_DsGetDCInfo01;
+
+       typedef struct {
+               [range(0,10000)] uint32 count;
+               [size_is(count)] drsuapi_DsGetDCInfo01 *array;
+       } drsuapi_DsGetDCInfoCtr01;
+
+       typedef union {
+               [case(1)] drsuapi_DsGetDCInfoCtr1 ctr1;
+               [case(2)] drsuapi_DsGetDCInfoCtr2 ctr2;
+               [case(-1)] drsuapi_DsGetDCInfoCtr01 ctr01;
+       } drsuapi_DsGetDCInfoCtr;
+
+       /* maybe WERROR function */
+       NTSTATUS drsuapi_DsGetDomainControllerInfo(
+               [in,ref] policy_handle *bind_handle,
+               [in, out] int32 level,
+               [in,switch_is(level)] drsuapi_DsGetDCInfoRequest req,
+               [out,switch_is(level)] drsuapi_DsGetDCInfoCtr ctr
+               );
 
        /*****************/
         /* Function 0x11 */
index 6e169e0c5cc08a3014248c73920804b633b1bae8..9b9f4df3fcdb0c5f64db3d8a96fba369238f27ed 100644 (file)
@@ -226,10 +226,10 @@ static NTSTATUS DRSUAPI_REMOVE_DS_DOMAIN(struct dcesrv_call_state *dce_call, TAL
 
 
 /* 
-  DRSUAPI_DOMAIN_CONTROLLER_INFO 
+  drsuapi_DsGetDomainControllerInfo 
 */
-static NTSTATUS DRSUAPI_DOMAIN_CONTROLLER_INFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                      struct DRSUAPI_DOMAIN_CONTROLLER_INFO *r)
+static NTSTATUS drsuapi_DsGetDomainControllerInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                      struct drsuapi_DsGetDomainControllerInfo *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
 }
index 4338950811f1649cce561ad93428708e054fafb4..a387aaa3372103a53e1c8588c1b11f848815b2cf 100644 (file)
@@ -23,8 +23,6 @@
 
 #include "includes.h"
 
-#define TEST_MACHINE_NAME "torturetest"
-
 static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
                      struct policy_handle *bind_handle)
 {
@@ -216,6 +214,86 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        return ret;
 }
 
+static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
+                     struct policy_handle *bind_handle)
+{
+       NTSTATUS status;
+       struct drsuapi_DsGetDomainControllerInfo r;
+       BOOL ret = True;
+
+       r.in.bind_handle = bind_handle;
+       r.in.level = 1;
+       r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm());
+       r.in.req.req1.level = 1;
+
+       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);
+               }
+               printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr);
+               ret = False;
+       }
+
+       r.in.req.req1.level = 2;
+
+       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);
+               }
+               printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr);
+               ret = False;
+       }
+
+       r.in.req.req1.level = -1;
+
+       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);
+               }
+               printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr);
+               ret = False;
+       }
+
+       r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup());
+       r.in.req.req1.level = 2;
+
+       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);
+               }
+               printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr);
+               ret = False;
+       }
+
+       r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__";
+       r.in.req.req1.level = 2;
+
+       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);
+               }
+
+               if (!NT_STATUS_EQUAL(status, NT_STATUS(0x0000208d))) {
+                       printf("drsuapi_DsGetDomainControllerInfo level %d with invalid domain name\n"
+                               " - %s != NTSTATUS[0x0000208d]\n",
+                                       r.in.req.req1.level, errstr);
+                       ret = False;
+               }
+       }
+
+       return ret;
+}
+
 static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
                        struct policy_handle *bind_handle)
 {
@@ -263,6 +341,10 @@ BOOL torture_rpc_drsuapi(int dummy)
                ret = False;
        }
 
+       if (!test_DsGetDCInfo(p, mem_ctx, &bind_handle)) {
+               ret = False;
+       }
+
        if (!test_DsCrackNames(p, mem_ctx, &bind_handle)) {
                ret = False;
        }