updated the 3.0 branch from the head branch - ready for alpha18
[nivanova/samba-autobuild/.git] / source3 / 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 2
36
37 /* use this inside a passdb module */
38 #define PDB_MODULE_VERSIONING_MAGIC \
39 int pdb_version(void)\
40 {\
41         return PASSDB_INTERFACE_VERSION;\
42 }
43
44 typedef struct pdb_context 
45 {
46         struct pdb_methods *pdb_methods;
47         struct pdb_methods *pwent_methods;
48         
49         /* These functions are wrappers for the functions listed above.
50            They may do extra things like re-reading a SAM_ACCOUNT on update */
51
52         BOOL (*pdb_setsampwent)(struct pdb_context *, BOOL update);
53         
54         void (*pdb_endsampwent)(struct pdb_context *);
55         
56         BOOL (*pdb_getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
57         
58         BOOL (*pdb_getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
59         
60         BOOL (*pdb_getsampwsid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, DOM_SID *sid);
61         
62         BOOL (*pdb_add_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
63         
64         BOOL (*pdb_update_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
65         
66         BOOL (*pdb_delete_sam_account)(struct pdb_context *, SAM_ACCOUNT *username);
67         
68         void (*free_fn)(struct pdb_context **);
69         
70         TALLOC_CTX *mem_ctx;
71         
72 } PDB_CONTEXT;
73
74 typedef struct pdb_methods 
75 {
76         const char *name; /* What name got this module */
77         struct pdb_context *parent;
78
79         /* Use macros from dlinklist.h on these two */
80         struct pdb_methods *next;
81         struct pdb_methods *prev;
82
83         BOOL (*setsampwent)(struct pdb_methods *, BOOL update);
84         
85         void (*endsampwent)(struct pdb_methods *);
86         
87         BOOL (*getsampwent)(struct pdb_methods *, SAM_ACCOUNT *user);
88         
89         BOOL (*getsampwnam)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const char *username);
90         
91         BOOL (*getsampwsid)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, DOM_SID *Sid);
92         
93         BOOL (*add_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
94         
95         BOOL (*update_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
96         
97         BOOL (*delete_sam_account)(struct pdb_methods *, SAM_ACCOUNT *username);
98         
99         void *private_data;  /* Private data of some kind */
100         
101         void (*free_private_data)(void **);
102
103 } PDB_METHODS;
104
105 typedef NTSTATUS (*pdb_init_function)(struct pdb_context *, 
106                          struct pdb_methods **, 
107                          const char *);
108
109 struct pdb_init_function_entry {
110         char *name;
111         /* Function to create a member of the pdb_methods list */
112         pdb_init_function init;
113 };
114
115 #endif /* _PASSDB_H */