ok next_rid out as well local_*id_to*id functions
[kai/samba.git] / source / include / passdb.h
1 /* 
2    Unix SMB/CIFS implementation.
3    passdb structures and parameters
4    Copyright (C) Gerald Carter 2001
5    Copyright (C) Luke Kenneth Casson Leighton 1998 - 2000
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 #ifndef _PASSDB_H
23 #define _PASSDB_H
24
25
26 /*****************************************************************
27  Functions to be implemented by the new (v2) passdb API 
28 ****************************************************************/
29
30 /*
31  * This next constant specifies the version number of the PASSDB interface
32  * this SAMBA will load. Increment this if *ANY* changes are made to the interface. 
33  */
34
35 #define PASSDB_INTERFACE_VERSION 4
36
37 typedef struct pdb_context 
38 {
39         struct pdb_methods *pdb_methods;
40         struct pdb_methods *pwent_methods;
41         
42         /* These functions are wrappers for the functions listed above.
43            They may do extra things like re-reading a SAM_ACCOUNT on update */
44
45         NTSTATUS (*pdb_setsampwent)(struct pdb_context *, BOOL update);
46         
47         void (*pdb_endsampwent)(struct pdb_context *);
48         
49         NTSTATUS (*pdb_getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
50         
51         NTSTATUS (*pdb_getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
52         
53         NTSTATUS (*pdb_getsampwsid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const DOM_SID *sid);
54
55         NTSTATUS (*pdb_add_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
56         
57         NTSTATUS (*pdb_update_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
58         
59         NTSTATUS (*pdb_delete_sam_account)(struct pdb_context *, SAM_ACCOUNT *username);
60
61         NTSTATUS (*pdb_getgrsid)(struct pdb_context *context, GROUP_MAP *map,
62                                  DOM_SID sid, BOOL with_priv);
63         
64         NTSTATUS (*pdb_getgrgid)(struct pdb_context *context, GROUP_MAP *map,
65                                  gid_t gid, BOOL with_priv);
66         
67         NTSTATUS (*pdb_getgrnam)(struct pdb_context *context, GROUP_MAP *map,
68                                  char *name, BOOL with_priv);
69         
70         NTSTATUS (*pdb_add_group_mapping_entry)(struct pdb_context *context,
71                                                 GROUP_MAP *map);
72         
73         NTSTATUS (*pdb_update_group_mapping_entry)(struct pdb_context *context,
74                                                    GROUP_MAP *map);
75         
76         NTSTATUS (*pdb_delete_group_mapping_entry)(struct pdb_context *context,
77                                                    DOM_SID sid);
78         
79         NTSTATUS (*pdb_enum_group_mapping)(struct pdb_context *context,
80                                            enum SID_NAME_USE sid_name_use,
81                                            GROUP_MAP **rmap, int *num_entries,
82                                            BOOL unix_only, BOOL with_priv);
83
84         void (*free_fn)(struct pdb_context **);
85         
86         TALLOC_CTX *mem_ctx;
87         
88 } PDB_CONTEXT;
89
90 typedef struct pdb_methods 
91 {
92         const char *name; /* What name got this module */
93         struct pdb_context *parent;
94
95         /* Use macros from dlinklist.h on these two */
96         struct pdb_methods *next;
97         struct pdb_methods *prev;
98
99         NTSTATUS (*setsampwent)(struct pdb_methods *, BOOL update);
100         
101         void (*endsampwent)(struct pdb_methods *);
102         
103         NTSTATUS (*getsampwent)(struct pdb_methods *, SAM_ACCOUNT *user);
104         
105         NTSTATUS (*getsampwnam)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const char *username);
106         
107         NTSTATUS (*getsampwsid)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const DOM_SID *sid);
108         
109         NTSTATUS (*add_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
110         
111         NTSTATUS (*update_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
112         
113         NTSTATUS (*delete_sam_account)(struct pdb_methods *, SAM_ACCOUNT *username);
114         
115         NTSTATUS (*getgrsid)(struct pdb_methods *methods, GROUP_MAP *map,
116                              DOM_SID sid, BOOL with_priv);
117
118         NTSTATUS (*getgrgid)(struct pdb_methods *methods, GROUP_MAP *map,
119                              gid_t gid, BOOL with_priv);
120
121         NTSTATUS (*getgrnam)(struct pdb_methods *methods, GROUP_MAP *map,
122                              char *name, BOOL with_priv);
123
124         NTSTATUS (*add_group_mapping_entry)(struct pdb_methods *methods,
125                                             GROUP_MAP *map);
126
127         NTSTATUS (*update_group_mapping_entry)(struct pdb_methods *methods,
128                                                GROUP_MAP *map);
129
130         NTSTATUS (*delete_group_mapping_entry)(struct pdb_methods *methods,
131                                                DOM_SID sid);
132
133         NTSTATUS (*enum_group_mapping)(struct pdb_methods *methods,
134                                        enum SID_NAME_USE sid_name_use,
135                                        GROUP_MAP **rmap, int *num_entries,
136                                        BOOL unix_only, BOOL with_priv);
137
138         void *private_data;  /* Private data of some kind */
139         
140         void (*free_private_data)(void **);
141
142 } PDB_METHODS;
143
144 typedef NTSTATUS (*pdb_init_function)(struct pdb_context *, 
145                          struct pdb_methods **, 
146                          const char *);
147
148 struct pdb_init_function_entry {
149         const char *name;
150         /* Function to create a member of the pdb_methods list */
151         pdb_init_function init;
152         struct pdb_init_function_entry *prev, *next;
153 };
154
155 #endif /* _PASSDB_H */