r61: - Implement first call in the winreg rpc server
[samba.git] / source4 / lib / registry / reg_backend_ldb / reg_backend_ldb.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Registry interface
4    Copyright (C) Jelmer Vernooij                                          2004.
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22 #include "lib/registry/common/registry.h"
23
24 /* 
25  * Saves the dn as private_data for every key/val
26  */
27
28 static BOOL ldb_open_registry(REG_HANDLE *handle, const char *location, BOOL try_full_load)
29 {
30         struct ldb_context *c;
31         c = ldb_connect(location, 0, NULL);
32
33         if(!c) return False;
34
35         handle->backend_data = c;
36         
37         return True;
38 }
39
40 static BOOL ldb_close_registry(REG_HANDLE *h) 
41 {
42         ldb_close(h);
43         return True;
44 }
45
46 static BOOL ldb_fetch_subkeys(REG_KEY *k, int *count, REG_KEY ***subkeys)
47 {
48         ldb_search();
49 }
50
51 static REG_KEY *ldb_open_key(REG_HANDLE *h, const char *name)
52 {
53         struct ldb_context *c = h->backend_data;
54         char *path;
55         struct ldb_message **msg;
56         REG_KEY *key = NULL;
57         (dn=key=Systems,
58         if(ldb_search(c, NULL, LDP_SCOPE_BASE, "", NULL,&msg) > 0) {
59                 key = reg_key_new_abs(name, h, base);
60         }
61
62         ldap_search_free(c, msg);
63
64         return key;
65 }
66
67 static REG_OPS reg_backend_ldb = {
68         .name = "ldb",
69         .open_registry = ldb_open_registry,
70         .close_registry = ldb_close_registry,
71         .open_key = ldb_open_key,
72         .fetch_subkeys = ldb_fetch_subkeys,
73 };
74
75 NTSTATUS reg_ldb_init(void)
76 {
77         return register_backend("registry", &reg_backend_ldb);
78 }