r23380: netr_getdcname returns WERROR not NTSTATUS.
[ira/wip.git] / source3 / rpc_client / cli_reg.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RPC Pipe client
4  
5    Copyright (C) Gerald (Jerry) Carter        2005-2006
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23 #include "rpc_client.h"
24
25 /*******************************************************************
26  connect to a registry hive root (open a registry policy)
27 *******************************************************************/
28
29 NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
30                          uint32 reg_type, uint32 access_mask,
31                          POLICY_HND *reg_hnd)
32 {
33         ZERO_STRUCTP(reg_hnd);
34
35         switch (reg_type)
36         {
37         case HKEY_CLASSES_ROOT:
38                 return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL, 
39                         access_mask, reg_hnd );
40
41         case HKEY_LOCAL_MACHINE:
42                 return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL, 
43                         access_mask, reg_hnd );
44
45         case HKEY_USERS:
46                 return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL, 
47                         access_mask, reg_hnd );
48
49         case HKEY_PERFORMANCE_DATA:
50                 return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL, 
51                         access_mask, reg_hnd );
52
53         default:
54                 /* fall through to end of function */
55                 break;
56         }
57
58         return NT_STATUS_INVALID_PARAMETER;
59 }
60
61 /*******************************************************************
62  Fill in a REGVAL_BUFFER for the data given a REGISTRY_VALUE
63  *******************************************************************/
64
65 uint32 reg_init_regval_buffer( REGVAL_BUFFER *buf2, REGISTRY_VALUE *val )
66 {
67         uint32          real_size = 0;
68         
69         if ( !buf2 || !val )
70                 return 0;
71                 
72         real_size = regval_size(val);
73         init_regval_buffer( buf2, (unsigned char*)regval_data_p(val), real_size );
74
75         return real_size;
76 }