This is another *BIG* change...
[kai/samba.git] / source3 / include / passdb.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    passdb structures and parameters
5    Copyright (C) Gerald Carter 2001
6    Copyright (C) Luke Kenneth Casson Leighton 1998 - 2000
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef _PASSDB_H
24 #define _PASSDB_H
25
26
27 /*****************************************************************
28  Functions to be implemented by the new (v2) passdb API 
29 ****************************************************************/
30
31 typedef struct pdb_context 
32 {
33         struct pdb_methods *pdb_selected;
34         
35         /* These functions are wrappers for the functions listed above.
36            They may do extra things like re-reading a SAM_ACCOUNT on update */
37
38         BOOL (*pdb_setsampwent)(struct pdb_context *, BOOL update);
39         
40         void (*pdb_endsampwent)(struct pdb_context *);
41         
42         BOOL (*pdb_getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
43         
44         BOOL (*pdb_getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
45         
46         BOOL (*pdb_getsampwrid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, uint32 rid);
47         
48         BOOL (*pdb_add_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
49         
50         BOOL (*pdb_update_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
51         
52         BOOL (*pdb_delete_sam_account)(struct pdb_context *, SAM_ACCOUNT *username);
53         
54         void (*free_fn)(struct pdb_context **);
55         
56         TALLOC_CTX *mem_ctx;
57         
58 } PDB_CONTEXT;
59
60 typedef struct pdb_methods 
61 {
62         char *name; /* What name got this module */
63
64         BOOL (*setsampwent)(struct pdb_context *, BOOL update);
65         
66         void (*endsampwent)(struct pdb_context *);
67         
68         BOOL (*getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
69         
70         BOOL (*getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
71         
72         BOOL (*getsampwrid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, uint32 rid);
73         
74         BOOL (*add_sam_account)(struct pdb_context *, const SAM_ACCOUNT *sampass);
75         
76         BOOL (*update_sam_account)(struct pdb_context *, const SAM_ACCOUNT *sampass);
77         
78         BOOL (*delete_sam_account)(struct pdb_context *, const SAM_ACCOUNT *username);
79         
80         void *private_data;  /* Private data of some kind */
81         
82         void (*free_private_data)(void **);
83
84 } PDB_METHODS;
85
86
87 struct pdb_init_function {
88         char *name;
89         /* Function to create a member of the authmethods list */
90         NTSTATUS (*init)(struct pdb_context *pdb_context, 
91                          struct pdb_methods **pdb_method, 
92                          const char *location);
93 };
94
95 #endif /* _PASSDB_H */