2 * Test password backend for samba
3 * Copyright (C) Jelmer Vernooij 2002
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)
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
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.
23 static int testsam_debug_level
= DBGC_ALL
;
26 #define DBGC_CLASS testsam_debug_level
28 /* define the version of the passdb interface */
29 PDB_MODULE_VERSIONING_MAGIC
31 /***************************************************************
32 Start enumeration of the passwd list.
33 ****************************************************************/
35 static BOOL
testsam_setsampwent(struct pdb_methods
*methods
, BOOL update
)
37 DEBUG(10, ("testsam_setsampwent called\n"));
41 /***************************************************************
42 End enumeration of the passwd list.
43 ****************************************************************/
45 static void testsam_endsampwent(struct pdb_methods
*methods
)
47 DEBUG(10, ("testsam_endsampwent called\n"));
50 /*****************************************************************
51 Get one SAM_ACCOUNT from the list (next in line)
52 *****************************************************************/
54 static BOOL
testsam_getsampwent(struct pdb_methods
*methods
, SAM_ACCOUNT
*user
)
56 DEBUG(10, ("testsam_getsampwent called\n"));
60 /******************************************************************
61 Lookup a name in the SAM database
62 ******************************************************************/
64 static BOOL
testsam_getsampwnam (struct pdb_methods
*methods
, SAM_ACCOUNT
*user
, const char *sname
)
66 DEBUG(10, ("testsam_getsampwnam called\n"));
70 /***************************************************************************
72 **************************************************************************/
74 static BOOL
testsam_getsampwsid (struct pdb_methods
*methods
, SAM_ACCOUNT
*user
, const DOM_SID
*sid
)
76 DEBUG(10, ("testsam_getsampwsid called\n"));
80 /***************************************************************************
82 ****************************************************************************/
84 static BOOL
testsam_delete_sam_account(struct pdb_methods
*methods
, SAM_ACCOUNT
*sam_pass
)
86 DEBUG(10, ("testsam_delete_sam_account called\n"));
90 /***************************************************************************
91 Modifies an existing SAM_ACCOUNT
92 ****************************************************************************/
94 static BOOL
testsam_update_sam_account (struct pdb_methods
*methods
, SAM_ACCOUNT
*newpwd
)
96 DEBUG(10, ("testsam_update_sam_account called\n"));
100 /***************************************************************************
101 Adds an existing SAM_ACCOUNT
102 ****************************************************************************/
104 static BOOL
testsam_add_sam_account (struct pdb_methods
*methods
, SAM_ACCOUNT
*newpwd
)
106 DEBUG(10, ("testsam_add_sam_account called\n"));
110 NTSTATUS
pdb_init(PDB_CONTEXT
*pdb_context
, PDB_METHODS
**pdb_method
, const char *location
)
114 if (!NT_STATUS_IS_OK(nt_status
= make_pdb_methods(pdb_context
->mem_ctx
, pdb_method
))) {
118 (*pdb_method
)->name
= "testsam";
120 /* Functions your pdb module doesn't provide should be set
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
;
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
));
138 DEBUG(0, ("Initializing testsam\n"));
140 DEBUG(10, ("Location: %s\n", location
));