r13711: * Correctly handle acb_info/acct_flags as uint32 not as uint16.
[bbaumbach/samba-autobuild/.git] / examples / pdb / test.c
1 /*
2  * Test password backend for samba
3  * Copyright (C) Jelmer Vernooij 2002
4  * 
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  * 
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  * 
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 675
17  * Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20
21 #include "includes.h"
22
23 static int testsam_debug_level = DBGC_ALL;
24
25 #undef DBGC_CLASS
26 #define DBGC_CLASS testsam_debug_level
27
28 /***************************************************************
29  Start enumeration of the passwd list.
30 ****************************************************************/
31
32 static NTSTATUS testsam_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
33 {
34         DEBUG(10, ("testsam_setsampwent called\n"));
35         return NT_STATUS_NOT_IMPLEMENTED;
36 }
37
38 /***************************************************************
39  End enumeration of the passwd list.
40 ****************************************************************/
41
42 static void testsam_endsampwent(struct pdb_methods *methods)
43 {
44         DEBUG(10, ("testsam_endsampwent called\n"));
45 }
46
47 /*****************************************************************
48  Get one SAM_ACCOUNT from the list (next in line)
49 *****************************************************************/
50
51 static NTSTATUS testsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
52 {
53         DEBUG(10, ("testsam_getsampwent called\n"));
54         return NT_STATUS_NOT_IMPLEMENTED;
55 }
56
57 /******************************************************************
58  Lookup a name in the SAM database
59 ******************************************************************/
60
61 static NTSTATUS testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
62 {
63         DEBUG(10, ("testsam_getsampwnam called\n"));
64         return NT_STATUS_NOT_IMPLEMENTED;
65 }
66
67 /***************************************************************************
68  Search by sid
69  **************************************************************************/
70
71 static NTSTATUS testsam_getsampwsid (struct pdb_methods *methods, SAM_ACCOUNT *user, const DOM_SID *sid)
72 {
73         DEBUG(10, ("testsam_getsampwsid called\n"));
74         return NT_STATUS_NOT_IMPLEMENTED;
75 }
76
77 /***************************************************************************
78  Delete a SAM_ACCOUNT
79 ****************************************************************************/
80
81 static NTSTATUS testsam_delete_sam_account(struct pdb_methods *methods, SAM_ACCOUNT *sam_pass)
82 {
83         DEBUG(10, ("testsam_delete_sam_account called\n"));
84         return NT_STATUS_NOT_IMPLEMENTED;
85 }
86
87 /***************************************************************************
88  Modifies an existing SAM_ACCOUNT
89 ****************************************************************************/
90
91 static NTSTATUS testsam_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
92 {
93         DEBUG(10, ("testsam_update_sam_account called\n"));
94         return NT_STATUS_NOT_IMPLEMENTED;
95 }
96
97 /***************************************************************************
98  Adds an existing SAM_ACCOUNT
99 ****************************************************************************/
100
101 static NTSTATUS testsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
102 {
103         DEBUG(10, ("testsam_add_sam_account called\n"));
104         return NT_STATUS_NOT_IMPLEMENTED;
105 }
106
107 NTSTATUS testsam_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
108 {
109         NTSTATUS nt_status;
110
111         if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods(pdb_context->mem_ctx, pdb_method))) {
112                 return nt_status;
113         }
114
115         (*pdb_method)->name = "testsam";
116
117         /* Functions your pdb module doesn't provide should not be
118            set, make_pdb_methods() already provide suitable defaults for missing functions */
119
120         (*pdb_method)->setsampwent = testsam_setsampwent;
121         (*pdb_method)->endsampwent = testsam_endsampwent;
122         (*pdb_method)->getsampwent = testsam_getsampwent;
123         (*pdb_method)->getsampwnam = testsam_getsampwnam;
124         (*pdb_method)->getsampwsid = testsam_getsampwsid;
125         (*pdb_method)->add_sam_account = testsam_add_sam_account;
126         (*pdb_method)->update_sam_account = testsam_update_sam_account;
127         (*pdb_method)->delete_sam_account = testsam_delete_sam_account;
128
129         testsam_debug_level = debug_add_class("testsam");
130         if (testsam_debug_level == -1) {
131                 testsam_debug_level = DBGC_ALL;
132                 DEBUG(0, ("testsam: Couldn't register custom debugging class!\n"));
133         } else DEBUG(0, ("testsam: Debug class number of 'testsam': %d\n", testsam_debug_level));
134     
135         DEBUG(0, ("Initializing testsam\n"));
136         if (location)
137                 DEBUG(10, ("Location: %s\n", location));
138
139         return NT_STATUS_OK;
140 }
141
142 NTSTATUS init_module(void) {
143         return smb_register_passdb(PASSDB_INTERFACE_VERSION, "testsam",
144                                    testsam_init);
145 }