added a wbtest program that shows how to access winbindd extended nss
[bbaumbach/samba-autobuild/.git] / examples / pdb / pdb_test.c
index 983a995d85866c67bd3a8e8789e96762fc761bfe..f5fb57ddb20acc7c2181595c567672b3cfd67e80 100644 (file)
 
 
 #include "includes.h"
+
 static int testsam_debug_level = DBGC_ALL;
+
 #undef DBGC_CLASS
 #define DBGC_CLASS testsam_debug_level
 
-static BOOL testsam_setsampwent(struct pdb_methods *methods, BOOL update)
+/***************************************************************
+ Start enumeration of the passwd list.
+****************************************************************/
+
+static NTSTATUS testsam_setsampwent(struct pdb_methods *methods, BOOL update)
 {
        DEBUG(10, ("testsam_setsampwent called\n"));
-       return True;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /***************************************************************
@@ -42,63 +48,63 @@ static void testsam_endsampwent(struct pdb_methods *methods)
  Get one SAM_ACCOUNT from the list (next in line)
 *****************************************************************/
 
-static BOOL testsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
+static NTSTATUS testsam_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
 {
        DEBUG(10, ("testsam_getsampwent called\n"));
-       return False;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /******************************************************************
  Lookup a name in the SAM database
 ******************************************************************/
 
-static BOOL testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
 {
        DEBUG(10, ("testsam_getsampwnam called\n"));
-       return False;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /***************************************************************************
- Search by rid
+ Search by sid
  **************************************************************************/
 
-static BOOL testsam_getsampwrid (struct pdb_methods *methods, SAM_ACCOUNT *user, uint32 rid)
+static NTSTATUS testsam_getsampwsid (struct pdb_methods *methods, SAM_ACCOUNT *user, const DOM_SID *sid)
 {
-       DEBUG(10, ("testsam_getsampwrid called\n"));
-       return False;
+       DEBUG(10, ("testsam_getsampwsid called\n"));
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /***************************************************************************
  Delete a SAM_ACCOUNT
 ****************************************************************************/
 
-static BOOL testsam_delete_sam_account(struct pdb_methods *methods, const SAM_ACCOUNT *sam_pass)
+static NTSTATUS testsam_delete_sam_account(struct pdb_methods *methods, SAM_ACCOUNT *sam_pass)
 {
        DEBUG(10, ("testsam_delete_sam_account called\n"));
-       return False;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /***************************************************************************
  Modifies an existing SAM_ACCOUNT
 ****************************************************************************/
 
-static BOOL testsam_update_sam_account (struct pdb_methods *methods, const SAM_ACCOUNT *newpwd)
+static NTSTATUS testsam_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
 {
        DEBUG(10, ("testsam_update_sam_account called\n"));
-       return False;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 /***************************************************************************
  Adds an existing SAM_ACCOUNT
 ****************************************************************************/
 
-static BOOL testsam_add_sam_account (struct pdb_methods *methods, const SAM_ACCOUNT *newpwd)
+static NTSTATUS testsam_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
 {
        DEBUG(10, ("testsam_add_sam_account called\n"));
-       return False;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+NTSTATUS testsam_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
 {
        NTSTATUS nt_status;
 
@@ -108,11 +114,14 @@ NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char
 
        (*pdb_method)->name = "testsam";
 
+       /* Functions your pdb module doesn't provide should be set 
+        * to NULL */
+
        (*pdb_method)->setsampwent = testsam_setsampwent;
        (*pdb_method)->endsampwent = testsam_endsampwent;
        (*pdb_method)->getsampwent = testsam_getsampwent;
        (*pdb_method)->getsampwnam = testsam_getsampwnam;
-       (*pdb_method)->getsampwrid = testsam_getsampwrid;
+       (*pdb_method)->getsampwsid = testsam_getsampwsid;
        (*pdb_method)->add_sam_account = testsam_add_sam_account;
        (*pdb_method)->update_sam_account = testsam_update_sam_account;
        (*pdb_method)->delete_sam_account = testsam_delete_sam_account;
@@ -129,3 +138,12 @@ NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char
 
        return NT_STATUS_OK;
 }
+
+int init_module(void);
+
+int init_module() {
+       if(smb_register_passdb("testsam", testsam_init, PASSDB_INTERFACE_VERSION))
+               return 0;
+
+       return 1;
+}