s4-ldb: cope better with corruption of tdb records
[Samba/aatanasov.git] / source3 / rpc_client / cli_reg.c
blobec200a24ae5c43de8130884d1a5be726fd09eebe
1 /*
2 Unix SMB/CIFS implementation.
3 RPC Pipe client
5 Copyright (C) Gerald (Jerry) Carter 2005-2006
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.
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.
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/>.
21 #include "includes.h"
22 #include "rpc_client.h"
24 /*******************************************************************
25 connect to a registry hive root (open a registry policy)
26 *******************************************************************/
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)
32 ZERO_STRUCTP(reg_hnd);
34 switch (reg_type)
36 case HKEY_CLASSES_ROOT:
37 return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL,
38 access_mask, reg_hnd, NULL);
40 case HKEY_LOCAL_MACHINE:
41 return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL,
42 access_mask, reg_hnd, NULL);
44 case HKEY_USERS:
45 return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL,
46 access_mask, reg_hnd, NULL);
48 case HKEY_CURRENT_USER:
49 return rpccli_winreg_OpenHKCU( cli, mem_ctx, NULL,
50 access_mask, reg_hnd, NULL);
52 case HKEY_PERFORMANCE_DATA:
53 return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL,
54 access_mask, reg_hnd, NULL);
56 default:
57 /* fall through to end of function */
58 break;
61 return NT_STATUS_INVALID_PARAMETER;