2 Unix SMB/CIFS implementation.
3 Password and authentication handling
4 Copyright (C) Andrew Bartlett 2002
5 Copyright (C) Jelmer Vernooij 2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DBGC_CLASS DBGC_PASSDB
27 static struct pdb_init_function_entry *backends = NULL;
29 static void lazy_initialize_passdb(void)
31 static BOOL initialized = False;
32 if(initialized)return;
37 static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name);
39 /*******************************************************************
40 Clean up uninitialised passwords. The only way to tell
41 that these values are not 'real' is that they do not
42 have a valid last set time. Instead, the value is fixed at 0.
43 Therefore we use that as the key for 'is this a valid password'.
44 However, it is perfectly valid to have a 'default' last change
45 time, such LDAP with a missing attribute would produce.
46 ********************************************************************/
48 static void pdb_force_pw_initialization(SAM_ACCOUNT *pass)
50 const char *lm_pwd, *nt_pwd;
52 /* only reset a password if the last set time has been
53 explicitly been set to zero. A default last set time
56 if ( (pdb_get_init_flags(pass, PDB_PASSLASTSET) != PDB_DEFAULT)
57 && (pdb_get_pass_last_set_time(pass) == 0) )
60 if (pdb_get_init_flags(pass, PDB_LMPASSWD) != PDB_DEFAULT)
62 lm_pwd = pdb_get_lanman_passwd(pass);
64 pdb_set_lanman_passwd(pass, NULL, PDB_CHANGED);
66 if (pdb_get_init_flags(pass, PDB_NTPASSWD) != PDB_DEFAULT)
68 nt_pwd = pdb_get_nt_passwd(pass);
70 pdb_set_nt_passwd(pass, NULL, PDB_CHANGED);
77 NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init)
79 struct pdb_init_function_entry *entry = backends;
81 if(version != PASSDB_INTERFACE_VERSION) {
82 DEBUG(0,("Can't register passdb backend!\n"
83 "You tried to register a passdb module with PASSDB_INTERFACE_VERSION %d, "
84 "while this version of samba uses version %d\n",
85 version,PASSDB_INTERFACE_VERSION));
86 return NT_STATUS_OBJECT_TYPE_MISMATCH;
90 return NT_STATUS_INVALID_PARAMETER;
93 DEBUG(5,("Attempting to register passdb backend %s\n", name));
95 /* Check for duplicates */
96 if (pdb_find_backend_entry(name)) {
97 DEBUG(0,("There already is a passdb backend registered with the name %s!\n", name));
98 return NT_STATUS_OBJECT_NAME_COLLISION;
101 entry = smb_xmalloc(sizeof(struct pdb_init_function_entry));
102 entry->name = smb_xstrdup(name);
105 DLIST_ADD(backends, entry);
106 DEBUG(5,("Successfully added passdb backend '%s'\n", name));
110 static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name)
112 struct pdb_init_function_entry *entry = backends;
115 if (strcmp(entry->name, name)==0) return entry;
122 static NTSTATUS context_setsampwent(struct pdb_context *context, BOOL update)
124 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
127 DEBUG(0, ("invalid pdb_context specified!\n"));
131 context->pwent_methods = context->pdb_methods;
133 if (!context->pwent_methods) {
134 /* No passdbs at all */
138 while (NT_STATUS_IS_ERR(ret = context->pwent_methods->setsampwent(context->pwent_methods, update))) {
139 context->pwent_methods = context->pwent_methods->next;
140 if (context->pwent_methods == NULL)
141 return NT_STATUS_UNSUCCESSFUL;
146 static void context_endsampwent(struct pdb_context *context)
149 DEBUG(0, ("invalid pdb_context specified!\n"));
153 if (context->pwent_methods && context->pwent_methods->endsampwent)
154 context->pwent_methods->endsampwent(context->pwent_methods);
156 /* So we won't get strange data when calling getsampwent now */
157 context->pwent_methods = NULL;
160 static NTSTATUS context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user)
162 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
164 if ((!context) || (!context->pwent_methods)) {
165 DEBUG(0, ("invalid pdb_context specified!\n"));
168 /* Loop until we find something useful */
169 while (NT_STATUS_IS_ERR(ret = context->pwent_methods->getsampwent(context->pwent_methods, user))) {
171 context->pwent_methods->endsampwent(context->pwent_methods);
173 context->pwent_methods = context->pwent_methods->next;
175 /* All methods are checked now. There are no more entries */
176 if (context->pwent_methods == NULL)
179 context->pwent_methods->setsampwent(context->pwent_methods, False);
181 user->methods = context->pwent_methods;
182 pdb_force_pw_initialization(user);
186 static NTSTATUS context_getsampwnam(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const char *username)
188 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
190 struct pdb_methods *curmethods;
192 DEBUG(0, ("invalid pdb_context specified!\n"));
195 curmethods = context->pdb_methods;
197 if (NT_STATUS_IS_OK(ret = curmethods->getsampwnam(curmethods, sam_acct, username))) {
198 pdb_force_pw_initialization(sam_acct);
199 sam_acct->methods = curmethods;
202 curmethods = curmethods->next;
208 static NTSTATUS context_getsampwsid(struct pdb_context *context, SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
210 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
212 struct pdb_methods *curmethods;
214 DEBUG(0, ("invalid pdb_context specified!\n"));
218 curmethods = context->pdb_methods;
221 if (NT_STATUS_IS_OK(ret = curmethods->getsampwsid(curmethods, sam_acct, sid))) {
222 pdb_force_pw_initialization(sam_acct);
223 sam_acct->methods = curmethods;
226 curmethods = curmethods->next;
232 static NTSTATUS context_add_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
234 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
235 const char *lm_pw, *nt_pw;
238 if ((!context) || (!context->pdb_methods)) {
239 DEBUG(0, ("invalid pdb_context specified!\n"));
243 /* disable acccounts with no passwords (that has not
244 been allowed by the ACB_PWNOTREQ bit */
246 lm_pw = pdb_get_lanman_passwd( sam_acct );
247 nt_pw = pdb_get_nt_passwd( sam_acct );
248 acb_flags = pdb_get_acct_ctrl( sam_acct );
249 if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) {
250 acb_flags |= ACB_DISABLED;
251 pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_CHANGED );
254 /** @todo This is where a 're-read on add' should be done */
255 /* We now add a new account to the first database listed.
258 return context->pdb_methods->add_sam_account(context->pdb_methods, sam_acct);
261 static NTSTATUS context_update_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
263 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
264 const char *lm_pw, *nt_pw;
268 DEBUG(0, ("invalid pdb_context specified!\n"));
272 if (!sam_acct || !sam_acct->methods){
273 DEBUG(0, ("invalid sam_acct specified\n"));
277 /* disable acccounts with no passwords (that has not
278 been allowed by the ACB_PWNOTREQ bit */
280 lm_pw = pdb_get_lanman_passwd( sam_acct );
281 nt_pw = pdb_get_nt_passwd( sam_acct );
282 acb_flags = pdb_get_acct_ctrl( sam_acct );
283 if ( !lm_pw && !nt_pw && !(acb_flags&ACB_PWNOTREQ) ) {
284 acb_flags |= ACB_DISABLED;
285 pdb_set_acct_ctrl( sam_acct, acb_flags, PDB_CHANGED );
288 /** @todo This is where a 're-read on update' should be done */
290 return sam_acct->methods->update_sam_account(sam_acct->methods, sam_acct);
293 static NTSTATUS context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT *sam_acct)
295 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
297 struct pdb_methods *pdb_selected;
299 DEBUG(0, ("invalid pdb_context specified!\n"));
303 if (!sam_acct->methods){
304 pdb_selected = context->pdb_methods;
305 /* There's no passdb backend specified for this account.
306 * Try to delete it in every passdb available
307 * Needed to delete accounts in smbpasswd that are not
310 while (pdb_selected){
311 if (NT_STATUS_IS_OK(ret = pdb_selected->delete_sam_account(pdb_selected, sam_acct))) {
314 pdb_selected = pdb_selected->next;
319 if (!sam_acct->methods->delete_sam_account){
320 DEBUG(0,("invalid sam_acct->methods->delete_sam_account\n"));
324 return sam_acct->methods->delete_sam_account(sam_acct->methods, sam_acct);
327 static NTSTATUS context_getgrsid(struct pdb_context *context,
328 GROUP_MAP *map, DOM_SID sid)
330 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
332 struct pdb_methods *curmethods;
334 DEBUG(0, ("invalid pdb_context specified!\n"));
337 curmethods = context->pdb_methods;
339 ret = curmethods->getgrsid(curmethods, map, sid);
340 if (NT_STATUS_IS_OK(ret)) {
341 map->methods = curmethods;
344 curmethods = curmethods->next;
350 static NTSTATUS context_getgrgid(struct pdb_context *context,
351 GROUP_MAP *map, gid_t gid)
353 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
355 struct pdb_methods *curmethods;
357 DEBUG(0, ("invalid pdb_context specified!\n"));
360 curmethods = context->pdb_methods;
362 ret = curmethods->getgrgid(curmethods, map, gid);
363 if (NT_STATUS_IS_OK(ret)) {
364 map->methods = curmethods;
367 curmethods = curmethods->next;
373 static NTSTATUS context_getgrnam(struct pdb_context *context,
374 GROUP_MAP *map, const char *name)
376 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
378 struct pdb_methods *curmethods;
380 DEBUG(0, ("invalid pdb_context specified!\n"));
383 curmethods = context->pdb_methods;
385 ret = curmethods->getgrnam(curmethods, map, name);
386 if (NT_STATUS_IS_OK(ret)) {
387 map->methods = curmethods;
390 curmethods = curmethods->next;
396 static NTSTATUS context_add_group_mapping_entry(struct pdb_context *context,
399 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
401 if ((!context) || (!context->pdb_methods)) {
402 DEBUG(0, ("invalid pdb_context specified!\n"));
406 return context->pdb_methods->add_group_mapping_entry(context->pdb_methods,
410 static NTSTATUS context_update_group_mapping_entry(struct pdb_context *context,
413 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
415 if ((!context) || (!context->pdb_methods)) {
416 DEBUG(0, ("invalid pdb_context specified!\n"));
421 pdb_methods->update_group_mapping_entry(context->pdb_methods, map);
424 static NTSTATUS context_delete_group_mapping_entry(struct pdb_context *context,
427 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
429 if ((!context) || (!context->pdb_methods)) {
430 DEBUG(0, ("invalid pdb_context specified!\n"));
435 pdb_methods->delete_group_mapping_entry(context->pdb_methods, sid);
438 static NTSTATUS context_enum_group_mapping(struct pdb_context *context,
439 enum SID_NAME_USE sid_name_use,
440 GROUP_MAP **rmap, int *num_entries,
443 NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
445 if ((!context) || (!context->pdb_methods)) {
446 DEBUG(0, ("invalid pdb_context specified!\n"));
450 return context->pdb_methods->enum_group_mapping(context->pdb_methods,
452 num_entries, unix_only);
455 /******************************************************************
456 Free and cleanup a pdb context, any associated data and anything
457 that the attached modules might have associated.
458 *******************************************************************/
460 static void free_pdb_context(struct pdb_context **context)
462 struct pdb_methods *pdb_selected = (*context)->pdb_methods;
464 while (pdb_selected){
465 if(pdb_selected->free_private_data)
466 pdb_selected->free_private_data(&(pdb_selected->private_data));
467 pdb_selected = pdb_selected->next;
470 talloc_destroy((*context)->mem_ctx);
474 /******************************************************************
475 Make a pdb_methods from scratch
476 *******************************************************************/
478 static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_context *context, const char *selected)
480 char *module_name = smb_xstrdup(selected);
481 char *module_location = NULL, *p;
482 struct pdb_init_function_entry *entry;
483 NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
485 lazy_initialize_passdb();
487 p = strchr(module_name, ':');
491 module_location = p+1;
492 trim_char(module_location, ' ', ' ');
495 trim_char(module_name, ' ', ' ');
498 DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
500 entry = pdb_find_backend_entry(module_name);
502 /* Try to find a module that contains this module */
504 DEBUG(2,("No builtin backend found, trying to load plugin\n"));
505 if(NT_STATUS_IS_OK(smb_probe_module("pdb", module_name)) && !(entry = pdb_find_backend_entry(module_name))) {
506 DEBUG(0,("Plugin is available, but doesn't register passdb backend %s\n", module_name));
507 SAFE_FREE(module_name);
508 return NT_STATUS_UNSUCCESSFUL;
512 /* No such backend found */
514 DEBUG(0,("No builtin nor plugin backend for %s found\n", module_name));
515 SAFE_FREE(module_name);
516 return NT_STATUS_INVALID_PARAMETER;
519 DEBUG(5,("Found pdb backend %s\n", module_name));
520 nt_status = entry->init(context, methods, module_location);
521 if (NT_STATUS_IS_OK(nt_status)) {
522 DEBUG(5,("pdb backend %s has a valid init\n", selected));
524 DEBUG(0,("pdb backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
526 SAFE_FREE(module_name);
530 /******************************************************************
531 Make a pdb_context from scratch.
532 *******************************************************************/
534 static NTSTATUS make_pdb_context(struct pdb_context **context)
538 mem_ctx = talloc_init("pdb_context internal allocation context");
541 DEBUG(0, ("make_pdb_context: talloc init failed!\n"));
542 return NT_STATUS_NO_MEMORY;
545 *context = talloc(mem_ctx, sizeof(**context));
547 DEBUG(0, ("make_pdb_context: talloc failed!\n"));
548 return NT_STATUS_NO_MEMORY;
551 ZERO_STRUCTP(*context);
553 (*context)->mem_ctx = mem_ctx;
555 (*context)->pdb_setsampwent = context_setsampwent;
556 (*context)->pdb_endsampwent = context_endsampwent;
557 (*context)->pdb_getsampwent = context_getsampwent;
558 (*context)->pdb_getsampwnam = context_getsampwnam;
559 (*context)->pdb_getsampwsid = context_getsampwsid;
560 (*context)->pdb_add_sam_account = context_add_sam_account;
561 (*context)->pdb_update_sam_account = context_update_sam_account;
562 (*context)->pdb_delete_sam_account = context_delete_sam_account;
563 (*context)->pdb_getgrsid = context_getgrsid;
564 (*context)->pdb_getgrgid = context_getgrgid;
565 (*context)->pdb_getgrnam = context_getgrnam;
566 (*context)->pdb_add_group_mapping_entry = context_add_group_mapping_entry;
567 (*context)->pdb_update_group_mapping_entry = context_update_group_mapping_entry;
568 (*context)->pdb_delete_group_mapping_entry = context_delete_group_mapping_entry;
569 (*context)->pdb_enum_group_mapping = context_enum_group_mapping;
571 (*context)->free_fn = free_pdb_context;
577 /******************************************************************
578 Make a pdb_context, given an array of strings
579 *******************************************************************/
581 NTSTATUS make_pdb_context_list(struct pdb_context **context, const char **selected)
584 struct pdb_methods *curmethods, *tmpmethods;
585 NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
586 BOOL have_guest = False;
588 if (!NT_STATUS_IS_OK(nt_status = make_pdb_context(context))) {
593 DEBUG(0, ("ERROR: empty passdb backend list!\n"));
598 if (strcmp(selected[i], "guest") == 0) {
601 /* Try to initialise pdb */
602 DEBUG(5,("Trying to load: %s\n", selected[i]));
603 if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods_name(&curmethods, *context, selected[i]))) {
604 DEBUG(1, ("Loading %s failed!\n", selected[i]));
605 free_pdb_context(context);
608 curmethods->parent = *context;
609 DLIST_ADD_END((*context)->pdb_methods, curmethods, tmpmethods);
616 if ( (lp_guestaccount() == NULL) ||
617 (*lp_guestaccount() == '\0') ) {
618 /* We explicitly don't want guest access. No idea what
619 else that breaks, but be it that way. */
623 if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods_name(&curmethods,
626 DEBUG(1, ("Loading guest module failed!\n"));
627 free_pdb_context(context);
631 curmethods->parent = *context;
632 DLIST_ADD_END((*context)->pdb_methods, curmethods, tmpmethods);
637 /******************************************************************
638 Make a pdb_context, given a text string.
639 *******************************************************************/
641 NTSTATUS make_pdb_context_string(struct pdb_context **context, const char *selected)
644 char **newsel = str_list_make(selected, NULL);
645 ret = make_pdb_context_list(context, (const char **)newsel);
646 str_list_free(&newsel);
650 /******************************************************************
651 Return an already initialised pdb_context, to facilitate backward
652 compatibility (see functions below).
653 *******************************************************************/
655 static struct pdb_context *pdb_get_static_context(BOOL reload)
657 static struct pdb_context *pdb_context = NULL;
659 if ((pdb_context) && (reload)) {
660 pdb_context->free_fn(&pdb_context);
661 if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
667 if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context, lp_passdb_backend()))) {
675 /******************************************************************
676 Backward compatibility functions for the original passdb interface
677 *******************************************************************/
679 BOOL pdb_setsampwent(BOOL update)
681 struct pdb_context *pdb_context = pdb_get_static_context(False);
687 return NT_STATUS_IS_OK(pdb_context->pdb_setsampwent(pdb_context, update));
690 void pdb_endsampwent(void)
692 struct pdb_context *pdb_context = pdb_get_static_context(False);
698 pdb_context->pdb_endsampwent(pdb_context);
701 BOOL pdb_getsampwent(SAM_ACCOUNT *user)
703 struct pdb_context *pdb_context = pdb_get_static_context(False);
709 return NT_STATUS_IS_OK(pdb_context->pdb_getsampwent(pdb_context, user));
712 BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
714 struct pdb_context *pdb_context = pdb_get_static_context(False);
720 return NT_STATUS_IS_OK(pdb_context->pdb_getsampwnam(pdb_context, sam_acct, username));
723 BOOL pdb_getsampwsid(SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
725 struct pdb_context *pdb_context = pdb_get_static_context(False);
731 return NT_STATUS_IS_OK(pdb_context->pdb_getsampwsid(pdb_context, sam_acct, sid));
734 BOOL pdb_add_sam_account(SAM_ACCOUNT *sam_acct)
736 struct pdb_context *pdb_context = pdb_get_static_context(False);
742 return NT_STATUS_IS_OK(pdb_context->pdb_add_sam_account(pdb_context, sam_acct));
745 BOOL pdb_update_sam_account(SAM_ACCOUNT *sam_acct)
747 struct pdb_context *pdb_context = pdb_get_static_context(False);
753 return NT_STATUS_IS_OK(pdb_context->pdb_update_sam_account(pdb_context, sam_acct));
756 BOOL pdb_delete_sam_account(SAM_ACCOUNT *sam_acct)
758 struct pdb_context *pdb_context = pdb_get_static_context(False);
764 return NT_STATUS_IS_OK(pdb_context->pdb_delete_sam_account(pdb_context, sam_acct));
767 BOOL pdb_getgrsid(GROUP_MAP *map, DOM_SID sid)
769 struct pdb_context *pdb_context = pdb_get_static_context(False);
775 return NT_STATUS_IS_OK(pdb_context->
776 pdb_getgrsid(pdb_context, map, sid));
779 BOOL pdb_getgrgid(GROUP_MAP *map, gid_t gid)
781 struct pdb_context *pdb_context = pdb_get_static_context(False);
787 return NT_STATUS_IS_OK(pdb_context->
788 pdb_getgrgid(pdb_context, map, gid));
791 BOOL pdb_getgrnam(GROUP_MAP *map, const char *name)
793 struct pdb_context *pdb_context = pdb_get_static_context(False);
799 return NT_STATUS_IS_OK(pdb_context->
800 pdb_getgrnam(pdb_context, map, name));
803 BOOL pdb_add_group_mapping_entry(GROUP_MAP *map)
805 struct pdb_context *pdb_context = pdb_get_static_context(False);
811 return NT_STATUS_IS_OK(pdb_context->
812 pdb_add_group_mapping_entry(pdb_context, map));
815 BOOL pdb_update_group_mapping_entry(GROUP_MAP *map)
817 struct pdb_context *pdb_context = pdb_get_static_context(False);
823 return NT_STATUS_IS_OK(pdb_context->
824 pdb_update_group_mapping_entry(pdb_context, map));
827 BOOL pdb_delete_group_mapping_entry(DOM_SID sid)
829 struct pdb_context *pdb_context = pdb_get_static_context(False);
835 return NT_STATUS_IS_OK(pdb_context->
836 pdb_delete_group_mapping_entry(pdb_context, sid));
839 BOOL pdb_enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap,
840 int *num_entries, BOOL unix_only)
842 struct pdb_context *pdb_context = pdb_get_static_context(False);
848 return NT_STATUS_IS_OK(pdb_context->
849 pdb_enum_group_mapping(pdb_context, sid_name_use,
850 rmap, num_entries, unix_only));
853 /***************************************************************
854 Initialize the static context (at smbd startup etc).
856 If uninitialised, context will auto-init on first use.
857 ***************************************************************/
859 BOOL initialize_password_db(BOOL reload)
861 return (pdb_get_static_context(reload) != NULL);
865 /***************************************************************************
866 Default implementations of some functions.
867 ****************************************************************************/
869 static NTSTATUS pdb_default_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
871 return NT_STATUS_NO_SUCH_USER;
874 static NTSTATUS pdb_default_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
876 return NT_STATUS_NO_SUCH_USER;
879 static NTSTATUS pdb_default_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
881 DEBUG(0,("this backend (%s) should not be listed as the first passdb backend! You can't add users to it.\n", methods->name));
882 return NT_STATUS_NOT_IMPLEMENTED;
885 static NTSTATUS pdb_default_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
887 return NT_STATUS_NOT_IMPLEMENTED;
890 static NTSTATUS pdb_default_delete_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *pwd)
892 return NT_STATUS_NOT_IMPLEMENTED;
895 static NTSTATUS pdb_default_setsampwent(struct pdb_methods *methods, BOOL update)
897 return NT_STATUS_NOT_IMPLEMENTED;
900 static NTSTATUS pdb_default_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
902 return NT_STATUS_NOT_IMPLEMENTED;
905 static void pdb_default_endsampwent(struct pdb_methods *methods)
907 return; /* NT_STATUS_NOT_IMPLEMENTED; */
910 NTSTATUS make_pdb_methods(TALLOC_CTX *mem_ctx, PDB_METHODS **methods)
912 *methods = talloc(mem_ctx, sizeof(struct pdb_methods));
915 return NT_STATUS_NO_MEMORY;
918 ZERO_STRUCTP(*methods);
920 (*methods)->setsampwent = pdb_default_setsampwent;
921 (*methods)->endsampwent = pdb_default_endsampwent;
922 (*methods)->getsampwent = pdb_default_getsampwent;
923 (*methods)->getsampwnam = pdb_default_getsampwnam;
924 (*methods)->getsampwsid = pdb_default_getsampwsid;
925 (*methods)->add_sam_account = pdb_default_add_sam_account;
926 (*methods)->update_sam_account = pdb_default_update_sam_account;
927 (*methods)->delete_sam_account = pdb_default_delete_sam_account;
929 (*methods)->getgrsid = pdb_default_getgrsid;
930 (*methods)->getgrgid = pdb_default_getgrgid;
931 (*methods)->getgrnam = pdb_default_getgrnam;
932 (*methods)->add_group_mapping_entry = pdb_default_add_group_mapping_entry;
933 (*methods)->update_group_mapping_entry = pdb_default_update_group_mapping_entry;
934 (*methods)->delete_group_mapping_entry = pdb_default_delete_group_mapping_entry;
935 (*methods)->enum_group_mapping = pdb_default_enum_group_mapping;