6d68d87a929ce433bd6e15b0da919009c7877e1f
[metze/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 3 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, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #include "includes.h"
21 #include "passdb.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  Lookup a name in the SAM database
30 ******************************************************************/
31
32 static NTSTATUS testsam_getsampwnam (struct pdb_methods *methods, struct samu *user, const char *sname)
33 {
34         DEBUG(10, ("testsam_getsampwnam called\n"));
35         return NT_STATUS_NOT_IMPLEMENTED;
36 }
37
38 /***************************************************************************
39  Search by sid
40  **************************************************************************/
41
42 static NTSTATUS testsam_getsampwsid (struct pdb_methods *methods, struct samu *user, const struct dom_sid *sid)
43 {
44         DEBUG(10, ("testsam_getsampwsid called\n"));
45         return NT_STATUS_NOT_IMPLEMENTED;
46 }
47
48 /***************************************************************************
49  Delete a struct samu
50 ****************************************************************************/
51
52 static NTSTATUS testsam_delete_sam_account(struct pdb_methods *methods, struct samu *sam_pass)
53 {
54         DEBUG(10, ("testsam_delete_sam_account called\n"));
55         return NT_STATUS_NOT_IMPLEMENTED;
56 }
57
58 /***************************************************************************
59  Modifies an existing struct samu
60 ****************************************************************************/
61
62 static NTSTATUS testsam_update_sam_account (struct pdb_methods *methods, struct samu *newpwd)
63 {
64         DEBUG(10, ("testsam_update_sam_account called\n"));
65         return NT_STATUS_NOT_IMPLEMENTED;
66 }
67
68 /***************************************************************************
69  Adds an existing struct samu
70 ****************************************************************************/
71
72 static NTSTATUS testsam_add_sam_account (struct pdb_methods *methods, struct samu *newpwd)
73 {
74         DEBUG(10, ("testsam_add_sam_account called\n"));
75         return NT_STATUS_NOT_IMPLEMENTED;
76 }
77
78 static NTSTATUS testsam_init(struct pdb_methods **pdb_method, const char *location)
79 {
80         NTSTATUS nt_status;
81
82         if (!NT_STATUS_IS_OK(nt_status = make_pdb_method( pdb_method ))) {
83                 return nt_status;
84         }
85
86         (*pdb_method)->name = "testsam";
87
88         /* Functions your pdb module doesn't provide should not be
89            set, make_pdb_methods() already provide suitable defaults for missing functions */
90
91         (*pdb_method)->getsampwnam = testsam_getsampwnam;
92         (*pdb_method)->getsampwsid = testsam_getsampwsid;
93         (*pdb_method)->add_sam_account = testsam_add_sam_account;
94         (*pdb_method)->update_sam_account = testsam_update_sam_account;
95         (*pdb_method)->delete_sam_account = testsam_delete_sam_account;
96
97         testsam_debug_level = debug_add_class("testsam");
98         if (testsam_debug_level == -1) {
99                 testsam_debug_level = DBGC_ALL;
100                 DEBUG(0, ("testsam: Couldn't register custom debugging class!\n"));
101         } else DEBUG(0, ("testsam: Debug class number of 'testsam': %d\n", testsam_debug_level));
102     
103         DEBUG(0, ("Initializing testsam\n"));
104         if (location)
105                 DEBUG(10, ("Location: %s\n", location));
106
107         return NT_STATUS_OK;
108 }
109
110 static_decl_pdb;
111 NTSTATUS pdb_test_init(void)
112 {
113         return smb_register_passdb(PASSDB_INTERFACE_VERSION, "testsam",
114                                    testsam_init);
115 }