This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[bbaumbach/samba-autobuild/.git] / examples / pdb / 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 /* define the version of the passdb interface */ 
29 PDB_MODULE_VERSIONING_MAGIC
30
31 /***************************************************************
32  Start enumeration of the passwd list.
33 ****************************************************************/
34
35 static NTSTATUS testsam_setsampwent(struct pdb_methods *methods, BOOL update)
36 {
37         DEBUG(10, ("testsam_setsampwent called\n"));
38         return NT_STATUS_NOT_IMPLEMENTED;
39 }
40
41 /***************************************************************
42  End enumeration of the passwd list.
43 ****************************************************************/
44
45 static void testsam_endsampwent(struct pdb_methods *methods)
46 {
47         DEBUG(10, ("testsam_endsampwent called\n"));
48 }
49
50 /*****************************************************************
51  Get one SAM_ACCOUNT from the list (next in line)
52 *****************************************************************/
53
54 static NTSTATUS testsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
55 {
56         DEBUG(10, ("testsam_getsampwent called\n"));
57         return NT_STATUS_NOT_IMPLEMENTED;
58 }
59
60 /******************************************************************
61  Lookup a name in the SAM database
62 ******************************************************************/
63
64 static NTSTATUS testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
65 {
66         DEBUG(10, ("testsam_getsampwnam called\n"));
67         return NT_STATUS_NOT_IMPLEMENTED;
68 }
69
70 /***************************************************************************
71  Search by sid
72  **************************************************************************/
73
74 static NTSTATUS testsam_getsampwsid (struct pdb_methods *methods, SAM_ACCOUNT *user, const DOM_SID *sid)
75 {
76         DEBUG(10, ("testsam_getsampwsid called\n"));
77         return NT_STATUS_NOT_IMPLEMENTED;
78 }
79
80 /***************************************************************************
81  Delete a SAM_ACCOUNT
82 ****************************************************************************/
83
84 static NTSTATUS testsam_delete_sam_account(struct pdb_methods *methods, SAM_ACCOUNT *sam_pass)
85 {
86         DEBUG(10, ("testsam_delete_sam_account called\n"));
87         return NT_STATUS_NOT_IMPLEMENTED;
88 }
89
90 /***************************************************************************
91  Modifies an existing SAM_ACCOUNT
92 ****************************************************************************/
93
94 static NTSTATUS testsam_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
95 {
96         DEBUG(10, ("testsam_update_sam_account called\n"));
97         return NT_STATUS_NOT_IMPLEMENTED;
98 }
99
100 /***************************************************************************
101  Adds an existing SAM_ACCOUNT
102 ****************************************************************************/
103
104 static NTSTATUS testsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
105 {
106         DEBUG(10, ("testsam_add_sam_account called\n"));
107         return NT_STATUS_NOT_IMPLEMENTED;
108 }
109
110 NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
111 {
112         NTSTATUS nt_status;
113
114         if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods(pdb_context->mem_ctx, pdb_method))) {
115                 return nt_status;
116         }
117
118         (*pdb_method)->name = "testsam";
119
120         /* Functions your pdb module doesn't provide should be set 
121          * to NULL */
122
123         (*pdb_method)->setsampwent = testsam_setsampwent;
124         (*pdb_method)->endsampwent = testsam_endsampwent;
125         (*pdb_method)->getsampwent = testsam_getsampwent;
126         (*pdb_method)->getsampwnam = testsam_getsampwnam;
127         (*pdb_method)->getsampwsid = testsam_getsampwsid;
128         (*pdb_method)->add_sam_account = testsam_add_sam_account;
129         (*pdb_method)->update_sam_account = testsam_update_sam_account;
130         (*pdb_method)->delete_sam_account = testsam_delete_sam_account;
131
132         testsam_debug_level = debug_add_class("testsam");
133         if (testsam_debug_level == -1) {
134                 testsam_debug_level = DBGC_ALL;
135                 DEBUG(0, ("testsam: Couldn't register custom debugging class!\n"));
136         } else DEBUG(0, ("testsam: Debug class number of 'testsam': %d\n", testsam_debug_level));
137     
138         DEBUG(0, ("Initializing testsam\n"));
139         if (location)
140                 DEBUG(10, ("Location: %s\n", location));
141
142         return NT_STATUS_OK;
143 }