r4168: Implement QueryValue in the server
authorJelmer Vernooij <jelmer@samba.org>
Mon, 13 Dec 2004 02:04:34 +0000 (02:04 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:21 +0000 (13:07 -0500)
IDL for NotifyChangeKeyValue

source/librpc/idl/winreg.idl
source/rpc_server/winreg/rpc_winreg.c
source/torture/rpc/winreg.c

index a293398b89f4d25ea8b16d1321c0b000ea6495f4..37049142d23652dfb259420198dfc03059bcd47e 100644 (file)
        /******************/
        /* Function: 0x0e */
        WERROR winreg_NotifyChangeKeyValue(
        /******************/
        /* Function: 0x0e */
        WERROR winreg_NotifyChangeKeyValue(
+               [in,ref] policy_handle *handle,
+               [in] uint8 watch_subtree,
+               [in] uint32 notify_filter,
+               [in] uint32 unknown,
+               [in] winreg_String string1,
+               [in] winreg_String string2, 
+               [in] uint32 unknown2
        );
 
        /******************/
        );
 
        /******************/
index 41147c089d0828ee367257ab54e679a16a41d8d7..e8d4056b2a211f573ba7d577bf94fe170a6caec2 100644 (file)
@@ -240,6 +240,11 @@ static WERROR winreg_FlushKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 static WERROR winreg_GetKeySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct winreg_GetKeySecurity *r)
 {
 static WERROR winreg_GetKeySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct winreg_GetKeySecurity *r)
 {
+       struct dcesrv_handle *h;
+
+       h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
+       DCESRV_CHECK_HANDLE(h);
+
        return WERR_NOT_SUPPORTED;
 }
 
        return WERR_NOT_SUPPORTED;
 }
 
@@ -341,7 +346,28 @@ static WERROR winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, TALLOC_CTX
 static WERROR winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct winreg_QueryValue *r)
 {
 static WERROR winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct winreg_QueryValue *r)
 {
-       return WERR_NOT_SUPPORTED;
+       struct dcesrv_handle *h;
+       struct registry_key *key;
+       struct registry_value *val;
+       WERROR result;
+
+       h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
+       DCESRV_CHECK_HANDLE(h);
+
+       key = h->data;
+       
+       result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name, &val);
+
+       if (!W_ERROR_IS_OK(result)) { 
+               return result;
+       }
+
+       r->out.type = &val->data_type;
+       r->out.size = r->in.size;
+       r->out.length = &val->data_len;
+       r->out.data = val->data_blk;
+
+       return WERR_OK;
 }
 
 
 }
 
 
index f84217532835a5fe22e1970b895a1f3e5ee0b204..97bf091d51d49677b6de218be4953c672ea37207 100644 (file)
@@ -60,6 +60,36 @@ static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        return True;
 }
 
        return True;
 }
 
+static BOOL test_NotifyChangeKeyValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
+                                                                         struct policy_handle *handle)
+{
+       struct winreg_NotifyChangeKeyValue r;
+       NTSTATUS status;
+
+       printf("\ntesting NotifyChangeKeyValue\n");
+
+       r.in.handle = handle;
+       r.in.watch_subtree = 1;
+       r.in.notify_filter = 0;
+       r.in.unknown = r.in.unknown2 = 0;
+       init_winreg_String(&r.in.string1, NULL);
+       init_winreg_String(&r.in.string2, NULL);
+
+       status = dcerpc_winreg_NotifyChangeKeyValue(p, mem_ctx, &r);
+       
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("NotifyChangeKeyValue failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("NotifyChangeKeyValue failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
+       return True;
+}
+
 static BOOL test_CreateKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                          struct policy_handle *handle, const char *name, 
                           const char *class)
 static BOOL test_CreateKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                          struct policy_handle *handle, const char *name, 
                           const char *class)
@@ -609,6 +639,9 @@ static BOOL test_key(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        }
 
 
        }
 
 
+       if (!test_NotifyChangeKeyValue(p, mem_ctx, handle)) {
+       }
+       
        if (!test_GetKeySecurity(p, mem_ctx, handle)) {
        }
 
        if (!test_GetKeySecurity(p, mem_ctx, handle)) {
        }