2 * Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
3 * Copyright (C) Andrew Tridgell 1992-1998
4 * Copyright (C) Simo Sorce 2000
5 * Copyright (C) Gerald Carter 2000
6 * Copyright (C) Jeremy Allison 2001
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 675
20 * Mass Ave, Cambridge, MA 02139, USA.
27 #define PDB_VERSION "20010830"
28 #define PASSDB_FILE_NAME "passdb.tdb"
29 #define TDB_FORMAT_STRING "ddddddBBBBBBBBBBBBddBBwdwdBdd"
30 #define USERPREFIX "USER_"
31 #define RIDPREFIX "RID_"
33 extern int DEBUGLEVEL
;
34 extern pstring samlogon_user
;
35 extern BOOL sam_logon_in_ssb
;
37 struct tdb_enum_info
{
38 TDB_CONTEXT
*passwd_tdb
;
42 static struct tdb_enum_info global_tdb_ent
;
43 /*static SAM_ACCOUNT global_sam_pass;*/
45 /**********************************************************************
46 Intialize a SAM_ACCOUNT struct from a BYTE buffer of size len
47 *********************************************************************/
49 static BOOL
init_sam_from_buffer (SAM_ACCOUNT
*sampass
, uint8
*buf
, uint32 buflen
)
52 /* times are stored as 32bit integer
53 take care on system with 64bit wide time_t
60 pass_must_change_time
;
73 uint32 username_len
, domain_len
, nt_username_len
,
74 dir_drive_len
, unknown_str_len
, munged_dial_len
,
75 fullname_len
, homedir_len
, logon_script_len
,
76 profile_path_len
, acct_desc_len
, workstations_len
;
78 uint32
/* uid, gid,*/ user_rid
, group_rid
, unknown_3
, hours_len
, unknown_5
, unknown_6
;
79 uint16 acct_ctrl
, logon_divs
;
81 static uint8
*lm_pw_ptr
, *nt_pw_ptr
;
83 uint32 lmpwlen
, ntpwlen
, hourslen
;
90 if(sampass
== NULL
|| buf
== NULL
) {
91 DEBUG(0, ("init_sam_from_buffer: NULL parameters found!\n"));
95 /* unpack the buffer into variables */
96 len
= tdb_unpack (buf
, buflen
, TDB_FORMAT_STRING
,
101 &pass_can_change_time
,
102 &pass_must_change_time
,
103 &username_len
, &username
,
104 &domain_len
, &domain
,
105 &nt_username_len
, &nt_username
,
106 &fullname_len
, &fullname
,
107 &homedir_len
, &homedir
,
108 &dir_drive_len
, &dir_drive
,
109 &logon_script_len
, &logon_script
,
110 &profile_path_len
, &profile_path
,
111 &acct_desc_len
, &acct_desc
,
112 &workstations_len
, &workstations
,
113 &unknown_str_len
, &unknown_str
,
114 &munged_dial_len
, &munged_dial
,
117 &lmpwlen
, &lm_pw_ptr
,
118 &ntpwlen
, &nt_pw_ptr
,
132 /* validate the account and fill in UNIX uid and gid. Standard
133 * getpwnam() is used instead of Get_Pwnam() as we do not need
134 * to try case permutations
136 if (!username
|| !(pw
=getpwnam(username
))) {
137 DEBUG(0,("tdb_sam: getpwnam(%s) return NULL. User does not exist!\n",
138 username
?username
:"NULL"));
145 pdb_set_uid(sampass
, uid
);
146 pdb_set_gid(sampass
, gid
);
148 pdb_set_logon_time(sampass
, logon_time
);
149 pdb_set_logoff_time(sampass
, logoff_time
);
150 pdb_set_kickoff_time(sampass
, kickoff_time
);
151 pdb_set_pass_can_change_time(sampass
, pass_can_change_time
);
152 pdb_set_pass_must_change_time(sampass
, pass_must_change_time
);
153 pdb_set_pass_last_set_time(sampass
, pass_last_set_time
);
155 pdb_set_username (sampass
, username_len
?username
:NULL
);
156 pdb_set_domain (sampass
, domain_len
?domain
:NULL
);
157 pdb_set_nt_username (sampass
, nt_username_len
?nt_username
:NULL
);
158 pdb_set_fullname (sampass
, fullname_len
?fullname
:NULL
);
160 if (homedir
) setflag
= True
;
163 homedir
= strdup(lp_logon_home());
164 if(!homedir
) { ret
= False
; goto done
; }
165 standard_sub_advanced(-1, username
, "", gid
, homedir
);
166 DEBUG(5,("Home directory set back to %s\n", homedir
));
168 pdb_set_homedir(sampass
, homedir
, setflag
);
170 if (dir_drive
) setflag
= True
;
173 dir_drive
= strdup(lp_logon_drive());
174 if(!dir_drive
) { ret
= False
; goto done
; }
175 standard_sub_advanced(-1, username
, "", gid
, dir_drive
);
176 DEBUG(5,("Home directory set back to %s\n", dir_drive
));
178 pdb_set_dir_drive(sampass
, dir_drive
, setflag
);
180 if (logon_script
) setflag
= True
;
183 logon_script
= strdup(lp_logon_script());
184 if(!logon_script
) { ret
= False
; goto done
; }
185 standard_sub_advanced(-1, username
, "", gid
, logon_script
);
186 DEBUG(5,("Home directory set back to %s\n", logon_script
));
188 pdb_set_logon_script(sampass
, logon_script
, setflag
);
190 if (profile_path
) setflag
= True
;
193 profile_path
= strdup(lp_logon_path());
194 if(!profile_path
) { ret
= False
; goto done
; }
195 standard_sub_advanced(-1, username
, "", gid
, profile_path
);
196 DEBUG(5,("Home directory set back to %s\n", profile_path
));
198 pdb_set_profile_path(sampass
, profile_path
, setflag
);
200 pdb_set_acct_desc (sampass
, acct_desc
);
201 pdb_set_workstations (sampass
, workstations
);
202 pdb_set_munged_dial (sampass
, munged_dial
);
203 if (!pdb_set_lanman_passwd(sampass
, lm_pw_ptr
)) {
207 if (!pdb_set_nt_passwd(sampass
, nt_pw_ptr
)) {
212 /*pdb_set_uid(sampass, uid);
213 pdb_set_gid(sampass, gid);*/
214 pdb_set_user_rid(sampass
, user_rid
);
215 pdb_set_group_rid(sampass
, group_rid
);
216 pdb_set_unknown_3(sampass
, unknown_3
);
217 pdb_set_hours_len(sampass
, hours_len
);
218 pdb_set_unknown_5(sampass
, unknown_5
);
219 pdb_set_unknown_6(sampass
, unknown_6
);
220 pdb_set_acct_ctrl(sampass
, acct_ctrl
);
221 pdb_set_logon_divs(sampass
, logon_divs
);
222 pdb_set_hours(sampass
, hours
);
228 SAFE_FREE(nt_username
);
231 SAFE_FREE(dir_drive
);
232 SAFE_FREE(logon_script
);
233 SAFE_FREE(profile_path
);
234 SAFE_FREE(acct_desc
);
235 SAFE_FREE(workstations
);
236 SAFE_FREE(munged_dial
);
241 /**********************************************************************
242 Intialize a BYTE buffer from a SAM_ACCOUNT struct
243 *********************************************************************/
244 static uint32
init_buffer_from_sam (uint8
**buf
, SAM_ACCOUNT
*sampass
)
248 /* times are stored as 32bit integer
249 take care on system with 64bit wide time_t
255 pass_can_change_time
,
256 pass_must_change_time
;
269 uint32 username_len
, domain_len
, nt_username_len
,
270 dir_drive_len
, unknown_str_len
, munged_dial_len
,
271 fullname_len
, homedir_len
, logon_script_len
,
272 profile_path_len
, acct_desc_len
, workstations_len
;
276 uint32 lm_pw_len
= 16;
277 uint32 nt_pw_len
= 16;
279 /* do we have a valid SAM_ACCOUNT pointer? */
280 if (sampass
== NULL
) {
281 DEBUG(0, ("init_buffer_from_sam: SAM_ACCOUNT is NULL!\n"));
288 logon_time
= (uint32
)pdb_get_logon_time(sampass
);
289 logoff_time
= (uint32
)pdb_get_logoff_time(sampass
);
290 kickoff_time
= (uint32
)pdb_get_kickoff_time(sampass
);
291 pass_can_change_time
= (uint32
)pdb_get_pass_can_change_time(sampass
);
292 pass_must_change_time
= (uint32
)pdb_get_pass_must_change_time(sampass
);
293 pass_last_set_time
= (uint32
)pdb_get_pass_last_set_time(sampass
);
296 username
= pdb_get_username(sampass
);
297 if (username
) username_len
= strlen(username
) +1;
298 else username_len
= 0;
300 domain
= pdb_get_domain(sampass
);
301 if (domain
) domain_len
= strlen(domain
) +1;
304 nt_username
= pdb_get_nt_username(sampass
);
305 if (nt_username
) nt_username_len
= strlen(nt_username
) +1;
306 else nt_username_len
= 0;
308 fullname
= pdb_get_fullname(sampass
);
309 if (fullname
) fullname_len
= strlen(fullname
) +1;
310 else fullname_len
= 0;
313 * Only updates fields which have been set (not defaults from smb.conf)
316 if (IS_SAM_SET(sampass
, FLAG_SAM_DRIVE
)) dir_drive
= pdb_get_dirdrive(sampass
);
317 else dir_drive
= NULL
;
318 if (dir_drive
) dir_drive_len
= strlen(dir_drive
) +1;
319 else dir_drive_len
= 0;
321 if (IS_SAM_SET(sampass
, FLAG_SAM_SMBHOME
)) homedir
= pdb_get_homedir(sampass
);
323 if (homedir
) homedir_len
= strlen(homedir
) +1;
324 else homedir_len
= 0;
326 if (IS_SAM_SET(sampass
, FLAG_SAM_LOGONSCRIPT
)) logon_script
= pdb_get_logon_script(sampass
);
327 else logon_script
= NULL
;
328 if (logon_script
) logon_script_len
= strlen(logon_script
) +1;
329 else logon_script_len
= 0;
331 if (IS_SAM_SET(sampass
, FLAG_SAM_PROFILE
)) profile_path
= pdb_get_profile_path(sampass
);
332 else profile_path
= NULL
;
333 if (profile_path
) profile_path_len
= strlen(profile_path
) +1;
334 else profile_path_len
= 0;
336 lm_pw
= pdb_get_lanman_passwd(sampass
);
337 if (!lm_pw
) lm_pw_len
= 0;
339 nt_pw
= pdb_get_nt_passwd(sampass
);
340 if (!nt_pw
) nt_pw_len
= 0;
342 acct_desc
= pdb_get_acct_desc(sampass
);
343 if (acct_desc
) acct_desc_len
= strlen(acct_desc
) +1;
344 else acct_desc_len
= 0;
346 workstations
= pdb_get_workstations(sampass
);
347 if (workstations
) workstations_len
= strlen(workstations
) +1;
348 else workstations_len
= 0;
353 munged_dial
= pdb_get_munged_dial(sampass
);
354 if (munged_dial
) munged_dial_len
= strlen(munged_dial
) +1;
355 else munged_dial_len
= 0;
357 /* one time to get the size needed */
358 len
= tdb_pack(NULL
, 0, TDB_FORMAT_STRING
,
363 pass_can_change_time
,
364 pass_must_change_time
,
365 username_len
, username
,
367 nt_username_len
, nt_username
,
368 fullname_len
, fullname
,
369 homedir_len
, homedir
,
370 dir_drive_len
, dir_drive
,
371 logon_script_len
, logon_script
,
372 profile_path_len
, profile_path
,
373 acct_desc_len
, acct_desc
,
374 workstations_len
, workstations
,
375 unknown_str_len
, unknown_str
,
376 munged_dial_len
, munged_dial
,
377 pdb_get_user_rid(sampass
),
378 pdb_get_group_rid(sampass
),
381 pdb_get_acct_ctrl(sampass
),
382 pdb_get_unknown3(sampass
),
383 pdb_get_logon_divs(sampass
),
384 pdb_get_hours_len(sampass
),
385 MAX_HOURS_LEN
, pdb_get_hours(sampass
),
386 pdb_get_unknown5(sampass
),
387 pdb_get_unknown6(sampass
));
390 /* malloc the space needed */
391 if ( (*buf
=(uint8
*)malloc(len
)) == NULL
) {
392 DEBUG(0,("init_buffer_from_sam: Unable to malloc() memory for buffer!\n"));
396 /* now for the real call to tdb_pack() */
397 buflen
= tdb_pack(*buf
, len
, TDB_FORMAT_STRING
,
402 pass_can_change_time
,
403 pass_must_change_time
,
404 username_len
, username
,
406 nt_username_len
, nt_username
,
407 fullname_len
, fullname
,
408 homedir_len
, homedir
,
409 dir_drive_len
, dir_drive
,
410 logon_script_len
, logon_script
,
411 profile_path_len
, profile_path
,
412 acct_desc_len
, acct_desc
,
413 workstations_len
, workstations
,
414 unknown_str_len
, unknown_str
,
415 munged_dial_len
, munged_dial
,
416 pdb_get_user_rid(sampass
),
417 pdb_get_group_rid(sampass
),
420 pdb_get_acct_ctrl(sampass
),
421 pdb_get_unknown3(sampass
),
422 pdb_get_logon_divs(sampass
),
423 pdb_get_hours_len(sampass
),
424 MAX_HOURS_LEN
, pdb_get_hours(sampass
),
425 pdb_get_unknown5(sampass
),
426 pdb_get_unknown6(sampass
));
429 /* check to make sure we got it correct */
439 /***************************************************************
440 Open the TDB passwd database for SAM account enumeration.
441 ****************************************************************/
443 BOOL
pdb_setsampwent(BOOL update
)
447 get_private_directory(tdbfile
);
448 pstrcat(tdbfile
, "/");
449 pstrcat(tdbfile
, PASSDB_FILE_NAME
);
451 /* Open tdb passwd */
452 if (!(global_tdb_ent
.passwd_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, update
?(O_RDWR
|O_CREAT
):O_RDONLY
, 0600)))
454 DEBUG(0, ("Unable to open/create TDB passwd\n"));
458 global_tdb_ent
.key
= tdb_firstkey(global_tdb_ent
.passwd_tdb
);
463 /***************************************************************
464 End enumeration of the TDB passwd list.
465 ****************************************************************/
467 void pdb_endsampwent(void)
469 if (global_tdb_ent
.passwd_tdb
) {
470 tdb_close(global_tdb_ent
.passwd_tdb
);
471 global_tdb_ent
.passwd_tdb
= NULL
;
474 DEBUG(7, ("endtdbpwent: closed sam database.\n"));
477 /*****************************************************************
478 Get one SAM_ACCOUNT from the TDB (next in line)
479 *****************************************************************/
481 BOOL
pdb_getsampwent(SAM_ACCOUNT
*user
)
487 char *prefix
= USERPREFIX
;
488 int prefixlen
= strlen (prefix
);
491 DEBUG(0,("pdb_get_sampwent: SAM_ACCOUNT is NULL.\n"));
495 /* skip all non-USER entries (eg. RIDS) */
496 while ((global_tdb_ent
.key
.dsize
!= 0) && (strncmp(global_tdb_ent
.key
.dptr
, prefix
, prefixlen
)))
497 /* increment to next in line */
498 global_tdb_ent
.key
= tdb_nextkey(global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
500 /* do we have an valid interation pointer? */
501 if(global_tdb_ent
.passwd_tdb
== NULL
) {
502 DEBUG(0,("pdb_get_sampwent: Bad TDB Context pointer.\n"));
506 data
= tdb_fetch(global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
508 DEBUG(5,("pdb_getsampwent: database entry not found.\n"));
512 /* unpack the buffer */
513 if (!init_sam_from_buffer(user
, data
.dptr
, data
.dsize
)) {
514 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
515 SAFE_FREE(data
.dptr
);
518 SAFE_FREE(data
.dptr
);
520 /* increment to next in line */
521 global_tdb_ent
.key
= tdb_nextkey(global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
526 /******************************************************************
527 Lookup a name in the SAM TDB
528 ******************************************************************/
530 BOOL
pdb_getsampwnam (SAM_ACCOUNT
*user
, char *sname
)
532 TDB_CONTEXT
*pwd_tdb
;
543 DEBUG(0,("pdb_getsampwnam: SAM_ACCOUNT is NULL.\n"));
547 /* Data is stored in all lower-case */
548 fstrcpy(name
, sname
);
551 get_private_directory(tdbfile
);
552 pstrcat(tdbfile
, "/");
553 pstrcat(tdbfile
, PASSDB_FILE_NAME
);
556 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
558 key
.dsize
= strlen(keystr
) + 1;
560 /* open the accounts TDB */
561 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDONLY
, 0600))) {
562 DEBUG(0, ("pdb_getsampwnam: Unable to open TDB passwd!\n"));
567 data
= tdb_fetch(pwd_tdb
, key
);
569 DEBUG(5,("pdb_getsampwnam (TDB): error fetching database.\n"));
570 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
575 /* unpack the buffer */
576 if (!init_sam_from_buffer(user
, data
.dptr
, data
.dsize
)) {
577 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
578 SAFE_FREE(data
.dptr
);
582 SAFE_FREE(data
.dptr
);
584 /* no further use for database, close it now */
590 /***************************************************************************
592 **************************************************************************/
594 BOOL
pdb_getsampwrid (SAM_ACCOUNT
*user
, uint32 rid
)
596 TDB_CONTEXT
*pwd_tdb
;
603 DEBUG(0,("pdb_getsampwrid: SAM_ACCOUNT is NULL.\n"));
607 get_private_directory(tdbfile
);
608 pstrcat(tdbfile
, "/");
609 pstrcat(tdbfile
, PASSDB_FILE_NAME
);
612 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, rid
);
614 key
.dsize
= strlen (keystr
) + 1;
616 /* open the accounts TDB */
617 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDONLY
, 0600))) {
618 DEBUG(0, ("pdb_getsampwrid: Unable to open TDB rid database!\n"));
623 data
= tdb_fetch (pwd_tdb
, key
);
625 DEBUG(5,("pdb_getsampwrid (TDB): error fetching database.\n"));
626 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
631 fstrcpy (name
, data
.dptr
);
632 SAFE_FREE(data
.dptr
);
636 return pdb_getsampwnam (user
, name
);
639 /***************************************************************************
641 ****************************************************************************/
643 BOOL
pdb_delete_sam_account(char *sname
)
645 SAM_ACCOUNT
*sam_pass
= NULL
;
646 TDB_CONTEXT
*pwd_tdb
;
653 fstrcpy(name
, sname
);
656 get_private_directory(tdbfile
);
657 pstrcat(tdbfile
, "/");
658 pstrcat(tdbfile
, PASSDB_FILE_NAME
);
661 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDWR
, 0600))) {
662 DEBUG(0, ("Unable to open TDB passwd!"));
666 /* set the search key */
667 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
669 key
.dsize
= strlen (keystr
) + 1;
672 data
= tdb_fetch (pwd_tdb
, key
);
674 DEBUG(5,("pdb_delete_sam_account (TDB): error fetching database.\n"));
675 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
680 /* unpack the buffer */
681 if (!pdb_init_sam (&sam_pass
)) {
686 if (!init_sam_from_buffer (sam_pass
, data
.dptr
, data
.dsize
)) {
687 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
689 SAFE_FREE(data
.dptr
);
692 SAFE_FREE(data
.dptr
);
694 rid
= pdb_get_user_rid(sam_pass
);
696 pdb_free_sam (sam_pass
);
698 /* it's outaa here! 8^) */
699 if (tdb_delete(pwd_tdb
, key
) != TDB_SUCCESS
) {
700 DEBUG(5, ("Error deleting entry from tdb passwd database!\n"));
701 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
706 /* delete also the RID key */
708 /* set the search key */
709 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, rid
);
711 key
.dsize
= strlen (keystr
) + 1;
713 /* it's outaa here! 8^) */
714 if (tdb_delete(pwd_tdb
, key
) != TDB_SUCCESS
) {
715 DEBUG(5, ("Error deleting entry from tdb rid database!\n"));
716 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
726 /***************************************************************************
728 ****************************************************************************/
730 static BOOL
tdb_update_sam(SAM_ACCOUNT
* newpwd
, BOOL override
, int flag
)
732 TDB_CONTEXT
*pwd_tdb
= NULL
;
740 get_private_directory(tdbfile
);
741 pstrcat(tdbfile
, "/");
742 pstrcat(tdbfile
, PASSDB_FILE_NAME
);
744 if ( (!newpwd
->uid
) || (!newpwd
->gid
) )
745 DEBUG (0,("tdb_update_sam: Storing a SAM_ACCOUNT for [%s] with uid %d and gid %d!\n",
746 newpwd
->username
, newpwd
->uid
, newpwd
->gid
));
748 /* if we don't have a RID, then generate one */
749 if (!newpwd
->user_rid
)
750 pdb_set_user_rid (newpwd
, pdb_uid_to_user_rid (newpwd
->uid
));
751 if (!newpwd
->group_rid
)
752 pdb_set_group_rid (newpwd
, pdb_gid_to_group_rid (newpwd
->gid
));
754 /* copy the SAM_ACCOUNT struct into a BYTE buffer for storage */
755 if ((data
.dsize
=init_buffer_from_sam (&buf
, newpwd
)) == -1) {
756 DEBUG(0,("tdb_update_sam: ERROR - Unable to copy SAM_ACCOUNT info BYTE buffer!\n"));
762 fstrcpy(name
,pdb_get_username(newpwd
));
765 /* setup the USER index key */
766 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
768 key
.dsize
= strlen (keystr
) + 1;
770 /* invalidate the existing TDB iterator if it is open */
771 if (global_tdb_ent
.passwd_tdb
) {
772 tdb_close(global_tdb_ent
.passwd_tdb
);
773 global_tdb_ent
.passwd_tdb
= NULL
;
776 /* open the account TDB passwd*/
777 pwd_tdb
= tdb_open_log(tdbfile
, 0, TDB_DEFAULT
, O_RDWR
| O_CREAT
, 0600);
780 DEBUG(0, ("tdb_update_sam: Unable to open TDB passwd!\n"));
784 /* add the account */
785 if (tdb_store(pwd_tdb
, key
, data
, flag
) != TDB_SUCCESS
) {
786 DEBUG(0, ("Unable to modify passwd TDB!"));
787 DEBUGADD(0, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
793 data
.dsize
= sizeof(fstring
);
796 /* setup the RID index key */
797 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, pdb_get_user_rid(newpwd
));
799 key
.dsize
= strlen (keystr
) + 1;
801 /* add the reference */
802 if (tdb_store(pwd_tdb
, key
, data
, flag
) != TDB_SUCCESS
) {
803 DEBUG(0, ("Unable to modify TDB passwd !"));
804 DEBUGADD(0, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
817 /***************************************************************************
818 Modifies an existing SAM_ACCOUNT
819 ****************************************************************************/
821 BOOL
pdb_update_sam_account (SAM_ACCOUNT
*newpwd
, BOOL override
)
823 return (tdb_update_sam(newpwd
, override
, TDB_MODIFY
));
826 /***************************************************************************
827 Adds an existing SAM_ACCOUNT
828 ****************************************************************************/
830 BOOL
pdb_add_sam_account (SAM_ACCOUNT
*newpwd
)
832 return (tdb_update_sam(newpwd
, True
, TDB_INSERT
));
836 /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
837 void samtdb_dummy_function(void) { } /* stop some compilers complaining */
838 #endif /* WITH_TDB_SAM */