r26151: Add IDL and torture test for wkssvc_NetrValidateName() and
authorGünther Deschner <gd@samba.org>
Tue, 27 Nov 2007 09:34:53 +0000 (10:34 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:46:25 +0000 (05:46 +0100)
wkssvc_NetrValidateName2().

Guenther
(This used to be commit 9f63ec388dab09ef3148635eefa58f2e32c5d151)

source4/librpc/idl/wkssvc.idl
source4/rpc_server/wkssvc/dcesrv_wkssvc.c
source4/torture/rpc/wkssvc.c

index cabd8a210d5c8e7e972766e53ebf8b4aa786cfc1..f84c6329c88e9109505a9eb161c084f5f2c297b8 100644 (file)
@@ -404,7 +404,22 @@ import "srvsvc.idl";
 
        /*****************************/
        /* Function        0x13      */
-       WERROR WKSSVC_NETRVALIDATENAME ();
+       typedef enum {
+               NetSetupUnknown = 0,
+               NetSetupMachine = 1,
+               NetSetupWorkgroup = 2,
+               NetSetupDomain = 3,
+               NetSetupNonExistentDomain = 4,
+               NetSetupDnsMachine = 5
+       } wkssvc_NetValidateNameType;
+
+       WERROR wkssvc_NetrValidateName(
+               [in] [string,charset(UTF16)] uint16 *server_name,
+               [in] [ref] [string,charset(UTF16)] uint16 *name,
+               [in] [string,charset(UTF16)] uint16 *Account,
+               [in] [string,charset(UTF16)] uint16 *Password,
+               [in] wkssvc_NetValidateNameType name_type
+               );
 
        /*****************************/
        /* Function        0x14      */
@@ -482,7 +497,13 @@ import "srvsvc.idl";
 
        /*****************************/
        /* Function        0x19      */
-       WERROR WKSSVC_NETRVALIDATENAME2 ();
+       WERROR wkssvc_NetrValidateName2(
+               [in] [string,charset(UTF16)] uint16 *server_name,
+               [in] [ref] [string,charset(UTF16)] uint16 *name,
+               [in] [string,charset(UTF16)] uint16 *Account,
+               [in] wkssvc_PasswordBuffer *EncryptedPassword,
+               [in] wkssvc_NetValidateNameType name_type
+               );
 
        /*****************************/
        /* Function        0x1a      */
index 3ab02c1047a57f892baff7ca90bcccd5b8355754..4123d9c9ce040c6e7e9350871b06e61a1a5343c5 100644 (file)
@@ -292,11 +292,11 @@ static WERROR dcesrv_WKSSVC_NETRRENAMEMACHINEINDOMAIN(struct dcesrv_call_state *
 }
 
 
-/* 
-  WKSSVC_NETRVALIDATENAME 
+/*
+  wkssvc_NetrValidateName
 */
-static WERROR dcesrv_WKSSVC_NETRVALIDATENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                      struct WKSSVC_NETRVALIDATENAME *r)
+static WERROR dcesrv_wkssvc_NetrValidateName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                      struct wkssvc_NetrValidateName *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
 }
@@ -352,11 +352,11 @@ static WERROR dcesrv_wkssvc_NetrRenameMachineInDomain2(struct dcesrv_call_state
 }
 
 
-/* 
-  WKSSVC_NETRVALIDATENAME2 
+/*
+  wkssvc_NetrValidateName2
 */
-static WERROR dcesrv_WKSSVC_NETRVALIDATENAME2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                      struct WKSSVC_NETRVALIDATENAME2 *r)
+static WERROR dcesrv_wkssvc_NetrValidateName2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                      struct wkssvc_NetrValidateName2 *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
 }
index f40af7353803cde6c2afe0973cb65dbdc04ed55e..d862e00d1d0e245ceb76402825e6a482346bffcb 100644 (file)
@@ -504,6 +504,66 @@ static bool test_NetrLogonDomainNameDel(struct torture_context *tctx,
        return true;
 }
 
+static bool test_NetrValidateName(struct torture_context *tctx,
+                                 struct dcerpc_pipe *p)
+{
+       NTSTATUS status;
+       struct wkssvc_NetrValidateName r;
+       uint16_t levels[] = {0,1,2,3,4,5};
+       int i;
+
+       for (i=0; i<ARRAY_SIZE(levels); i++) {
+
+               r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+               r.in.name = lp_workgroup(global_loadparm);
+               r.in.Account = NULL;
+               r.in.Password = NULL;
+               r.in.name_type = levels[i];
+
+               torture_comment(tctx, "testing NetrValidateName level %u\n",
+                               r.in.name_type);
+
+               status = dcerpc_wkssvc_NetrValidateName(p, tctx, &r);
+               torture_assert_ntstatus_ok(tctx, status,
+                                          "NetrValidateName failed");
+               torture_assert_werr_equal(tctx, r.out.result,
+                                         WERR_NOT_SUPPORTED,
+                                         "NetrValidateName failed");
+       }
+
+       return true;
+}
+
+static bool test_NetrValidateName2(struct torture_context *tctx,
+                                  struct dcerpc_pipe *p)
+{
+       NTSTATUS status;
+       struct wkssvc_NetrValidateName2 r;
+       uint16_t levels[] = {0,1,2,3,4,5};
+       int i;
+
+       for (i=0; i<ARRAY_SIZE(levels); i++) {
+
+               r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+               r.in.name = lp_workgroup(global_loadparm);
+               r.in.Account = NULL;
+               r.in.EncryptedPassword = NULL;
+               r.in.name_type = levels[i];
+
+               torture_comment(tctx, "testing NetrValidateName2 level %u\n",
+                               r.in.name_type);
+
+               status = dcerpc_wkssvc_NetrValidateName2(p, tctx, &r);
+               torture_assert_ntstatus_ok(tctx, status,
+                                          "NetrValidateName2 failed");
+               torture_assert_werr_equal(tctx, r.out.result,
+                                         WERR_RPC_E_REMOTE_DISABLED,
+                                         "NetrValidateName2 failed");
+       }
+
+       return true;
+}
+
 struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
 {
        struct torture_suite *suite;
@@ -537,6 +597,10 @@ struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
        torture_rpc_tcase_add_test(tcase, "NetrUseAdd",
                                   test_NetrUseAdd);
 
+       torture_rpc_tcase_add_test(tcase, "NetrValidateName",
+                                  test_NetrValidateName);
+       torture_rpc_tcase_add_test(tcase, "NetrValidateName2",
+                                  test_NetrValidateName2);
        torture_rpc_tcase_add_test(tcase, "NetrLogonDomainNameDel",
                                   test_NetrLogonDomainNameDel);
        torture_rpc_tcase_add_test(tcase, "NetrLogonDomainNameAdd",