s3: fix crash in winbindd
[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 3 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, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "rpc_client.h"
23
24 /*******************************************************************
25  connect to a registry hive root (open a registry policy)
26 *******************************************************************/
27
28 NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
29                          uint32 reg_type, uint32 access_mask,
30                          struct policy_handle *reg_hnd)
31 {
32         ZERO_STRUCTP(reg_hnd);
33
34         switch (reg_type)
35         {
36         case HKEY_CLASSES_ROOT:
37                 return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL, 
38                         access_mask, reg_hnd, NULL);
39
40         case HKEY_LOCAL_MACHINE:
41                 return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL, 
42                         access_mask, reg_hnd, NULL);
43
44         case HKEY_USERS:
45                 return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL, 
46                         access_mask, reg_hnd, NULL);
47
48         case HKEY_CURRENT_USER:
49                 return rpccli_winreg_OpenHKCU( cli, mem_ctx, NULL, 
50                         access_mask, reg_hnd, NULL);
51
52         case HKEY_PERFORMANCE_DATA:
53                 return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL, 
54                         access_mask, reg_hnd, NULL);
55
56         default:
57                 /* fall through to end of function */
58                 break;
59         }
60
61         return NT_STATUS_INVALID_PARAMETER;
62 }