r23800: LGPL is now called GNU Lesser General Public License
[amitay/samba.git] / source3 / include / idmap.h
1 #ifndef _IDMAP_H_
2 #define _IDMAP_H_
3 /* 
4    Unix SMB/CIFS implementation.
5
6    Idmap headers
7
8    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
9    Copyright (C) Simo Sorce 2003
10    
11    This library is free software; you can redistribute it and/or
12    modify it under the terms of the GNU Lesser General Public
13    License as published by the Free Software Foundation; either
14    version 3 of the License, or (at your option) any later version.
15    
16    This library is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    Library General Public License for more details.
20    
21    You should have received a copy of the GNU Lesser General Public License
22    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 /* idmap version determines auto-conversion - this is the database
26    structure version specifier. */
27
28 #define IDMAP_VERSION 2
29
30 /* The interface version specifier. 
31    Updated to 3 for enum types by JRA. */
32
33 /* Updated to 4, completely new interface, SSS */
34
35 #define SMB_IDMAP_INTERFACE_VERSION 4
36
37 struct idmap_domain {
38         const char *name;
39         BOOL default_domain;
40         BOOL readonly;
41         void *private_data;
42         struct idmap_methods *methods;
43         BOOL initialized;
44         const char *params;
45 };
46
47 /* Filled out by IDMAP backends */
48 struct idmap_methods {
49
50         /* Called when backend is first loaded */
51         NTSTATUS (*init)(struct idmap_domain *dom);
52
53         /* Map an array of uids/gids to SIDs.  The caller specifies
54            the uid/gid and type. Gets back the SID. */
55         NTSTATUS (*unixids_to_sids)(struct idmap_domain *dom, struct id_map **ids);
56
57         /* Map an arry of SIDs to uids/gids.  The caller sets the SID
58            and type and gets back a uid or gid. */
59         NTSTATUS (*sids_to_unixids)(struct idmap_domain *dom, struct id_map **ids);
60
61         NTSTATUS (*set_mapping)(struct idmap_domain *dom, const struct id_map *map);
62         NTSTATUS (*remove_mapping)(struct idmap_domain *dom, const struct id_map *map);
63
64         /* Called to dump backends data */
65         /* NOTE: caller must use talloc_free to free maps when done */
66         NTSTATUS (*dump_data)(struct idmap_domain *dom, struct id_map **maps, int *num_maps);
67
68         /* Called when backend is unloaded */
69         NTSTATUS (*close_fn)(struct idmap_domain *dom);
70 };
71
72 struct idmap_alloc_methods {
73
74         /* Called when backend is first loaded */
75         NTSTATUS (*init)(const char *compat_params);
76
77         NTSTATUS (*allocate_id)(struct unixid *id);
78         NTSTATUS (*get_id_hwm)(struct unixid *id);
79         NTSTATUS (*set_id_hwm)(struct unixid *id);
80
81         /* Called when backend is unloaded */
82         NTSTATUS (*close_fn)(void);
83 };
84
85 #endif /* _IDMAP_H_ */