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
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 675
19 * Mass Ave, Cambridge, MA 02139, USA.
26 #define PDB_VERSION "20010830"
27 #define PASSDB_FILE_NAME "/passdb.tdb"
28 #define TDB_FORMAT_STRING "ddddddBBBBBBBBBBBBddBBwdwdBdd"
29 #define USERPREFIX "USER_"
30 #define RIDPREFIX "RID_"
32 extern int DEBUGLEVEL
;
33 extern pstring samlogon_user
;
34 extern BOOL sam_logon_in_ssb
;
39 TDB_CONTEXT
*passwd_tdb
;
43 static struct tdb_enum_info global_tdb_ent
;
44 /*static SAM_ACCOUNT global_sam_pass;*/
46 /**********************************************************************
47 Intialize a SAM_ACCOUNT struct from a BYTE buffer of size len
48 *********************************************************************/
49 static BOOL
init_sam_from_buffer (SAM_ACCOUNT
*sampass
, uint8
*buf
,
53 /* times are stored as 32bit integer
54 take care on system with 64bit wide time_t
61 pass_must_change_time
;
74 uint32 username_len
, domain_len
, nt_username_len
,
75 dir_drive_len
, unknown_str_len
, munged_dial_len
,
76 fullname_len
, homedir_len
, logon_script_len
,
77 profile_path_len
, acct_desc_len
, workstations_len
;
79 uint32
/* uid, gid,*/ user_rid
, group_rid
, unknown_3
, hours_len
, unknown_5
, unknown_6
;
80 uint16 acct_ctrl
, logon_divs
;
82 static uint8
*lm_pw_ptr
,
85 uint32 lmpwlen
, ntpwlen
, hourslen
;
88 /* unpack the buffer into variables */
89 len
= tdb_unpack (buf
, buflen
, TDB_FORMAT_STRING
,
94 &pass_can_change_time
,
95 &pass_must_change_time
,
96 &username_len
, &username
,
98 &nt_username_len
, &nt_username
,
99 &fullname_len
, &fullname
,
100 &homedir_len
, &homedir
,
101 &dir_drive_len
, &dir_drive
,
102 &logon_script_len
, &logon_script
,
103 &profile_path_len
, &profile_path
,
104 &acct_desc_len
, &acct_desc
,
105 &workstations_len
, &workstations
,
106 &unknown_str_len
, &unknown_str
,
107 &munged_dial_len
, &munged_dial
,
110 &lmpwlen
, &lm_pw_ptr
,
111 &ntpwlen
, &nt_pw_ptr
,
123 pdb_set_logon_time(sampass
, logon_time
);
124 pdb_set_logoff_time(sampass
, logoff_time
);
125 pdb_set_kickoff_time(sampass
, kickoff_time
);
126 pdb_set_pass_can_change_time(sampass
, pass_can_change_time
);
127 pdb_set_pass_must_change_time(sampass
, pass_must_change_time
);
128 pdb_set_pass_last_set_time(sampass
, pass_last_set_time
);
130 pdb_set_username (sampass
, username_len
?username
:NULL
);
131 pdb_set_domain (sampass
, domain_len
?domain
:NULL
);
132 pdb_set_nt_username (sampass
, nt_username_len
?nt_username
:NULL
);
133 pdb_set_fullname (sampass
, fullname_len
?fullname
:NULL
);
134 pdb_set_homedir (sampass
, homedir_len
?homedir
:NULL
);
135 pdb_set_dir_drive (sampass
, dir_drive_len
?dir_drive
:NULL
);
136 pdb_set_logon_script (sampass
, logon_script_len
?logon_script
:NULL
);
137 pdb_set_profile_path (sampass
, profile_path_len
?profile_path
:NULL
);
138 pdb_set_acct_desc (sampass
, acct_desc_len
?acct_desc
:NULL
);
139 pdb_set_workstations (sampass
, workstations_len
?workstations
:NULL
);
140 pdb_set_munged_dial (sampass
, munged_dial_len
?munged_dial
:NULL
);
141 pdb_set_lanman_passwd(sampass
, lmpwlen
?lm_pw_ptr
:NULL
);
142 pdb_set_nt_passwd (sampass
, ntpwlen
?nt_pw_ptr
:NULL
);
144 /*pdb_set_uid(sampass, uid);
145 pdb_set_gid(sampass, gid);*/
146 pdb_set_user_rid(sampass
, user_rid
);
147 pdb_set_group_rid(sampass
, group_rid
);
148 pdb_set_unknown_3(sampass
, unknown_3
);
149 pdb_set_hours_len(sampass
, hours_len
);
150 pdb_set_unknown_5(sampass
, unknown_5
);
151 pdb_set_unknown_6(sampass
, unknown_6
);
152 pdb_set_acct_ctrl(sampass
, acct_ctrl
);
153 pdb_set_logons_divs(sampass
, logon_divs
);
154 pdb_set_hours(sampass
, hours
);
156 /* TODO: free TDB alloced memory !!!!! */
161 /**********************************************************************
162 Intialize a BYTE buffer from a SAM_ACCOUNT struct
163 *********************************************************************/
164 static uint32
init_buffer_from_sam (uint8
**buf
, SAM_ACCOUNT
*sampass
)
168 /* times are stored as 32bit integer
169 take care on system with 64bit wide time_t
175 pass_can_change_time
,
176 pass_must_change_time
;
189 uint32 username_len
, domain_len
, nt_username_len
,
190 dir_drive_len
, unknown_str_len
, munged_dial_len
,
191 fullname_len
, homedir_len
, logon_script_len
,
192 profile_path_len
, acct_desc_len
, workstations_len
;
196 uint32 lm_pw_len
= 16;
197 uint32 nt_pw_len
= 16;
199 /* do we have a valid SAM_ACCOUNT pointer? */
206 logon_time
= pdb_get_logon_time(sampass
);
207 logoff_time
= pdb_get_logoff_time(sampass
);
208 kickoff_time
= pdb_get_kickoff_time(sampass
);
209 pass_can_change_time
= pdb_get_pass_can_change_time(sampass
);
210 pass_must_change_time
= pdb_get_pass_must_change_time(sampass
);
211 pass_last_set_time
= pdb_get_pass_last_set_time(sampass
);
214 username
= pdb_get_username(sampass
);
215 if (username
) username_len
= strlen(username
) +1;
216 else username_len
= 0;
217 domain
= pdb_get_domain(sampass
);
218 if (domain
) domain_len
= strlen(domain
) +1;
220 nt_username
= pdb_get_nt_username(sampass
);
221 if (nt_username
) nt_username_len
= strlen(nt_username
) +1;
222 else nt_username_len
= 0;
223 dir_drive
= pdb_get_dirdrive(sampass
);
224 if (dir_drive
) dir_drive_len
= strlen(dir_drive
) +1;
225 else dir_drive_len
= 0;
228 munged_dial
= pdb_get_munged_dial(sampass
);
229 if (munged_dial
) munged_dial_len
= strlen(munged_dial
) +1;
230 else munged_dial_len
= 0;
232 fullname
= pdb_get_fullname(sampass
);
233 if (fullname
) fullname_len
= strlen(fullname
) +1;
234 else fullname_len
= 0;
235 homedir
= pdb_get_homedir(sampass
);
236 if (homedir
) homedir_len
= strlen(homedir
) +1;
237 else homedir_len
= 0;
238 logon_script
= pdb_get_logon_script(sampass
);
239 if (logon_script
) logon_script_len
= strlen(logon_script
) +1;
240 else logon_script_len
= 0;
241 profile_path
= pdb_get_profile_path(sampass
);
242 if (profile_path
) profile_path_len
= strlen(profile_path
) +1;
243 else profile_path_len
= 0;
244 acct_desc
= pdb_get_acct_desc(sampass
);
245 if (acct_desc
) acct_desc_len
= strlen(acct_desc
) +1;
246 else acct_desc_len
= 0;
247 workstations
= pdb_get_workstations(sampass
);
248 if (workstations
) workstations_len
= strlen(workstations
) +1;
249 else workstations_len
= 0;
251 lm_pw
= pdb_get_lanman_passwd(sampass
);
252 if (!lm_pw
) lm_pw_len
= 0;
254 nt_pw
= pdb_get_nt_passwd(sampass
);
255 if (!nt_pw
) nt_pw_len
= 0;
257 /* one time to get the size needed */
258 len
= tdb_pack(NULL
, 0, TDB_FORMAT_STRING
,
263 pass_can_change_time
,
264 pass_must_change_time
,
265 username_len
, username
,
267 nt_username_len
, nt_username
,
268 fullname_len
, fullname
,
269 homedir_len
, homedir
,
270 dir_drive_len
, dir_drive
,
271 logon_script_len
, logon_script
,
272 profile_path_len
, profile_path
,
273 acct_desc_len
, acct_desc
,
274 workstations_len
, workstations
,
275 unknown_str_len
, unknown_str
,
276 munged_dial_len
, munged_dial
,
277 pdb_get_user_rid(sampass
),
278 pdb_get_group_rid(sampass
),
281 pdb_get_acct_ctrl(sampass
),
282 pdb_get_unknown3(sampass
),
283 pdb_get_logon_divs(sampass
),
284 pdb_get_hours_len(sampass
),
285 MAX_HOURS_LEN
, pdb_get_hours(sampass
),
286 pdb_get_unknown5(sampass
),
287 pdb_get_unknown6(sampass
));
290 /* malloc the space needed */
291 if ( (*buf
=(uint8
*)malloc(len
)) == NULL
)
293 DEBUG(0,("init_buffer_from_sam: Unable to malloc() memory for buffer!\n"));
297 /* now for the real call to tdb_pack() */
298 buflen
= tdb_pack(*buf
, len
, TDB_FORMAT_STRING
,
303 pass_can_change_time
,
304 pass_must_change_time
,
305 username_len
, username
,
307 nt_username_len
, nt_username
,
308 fullname_len
, fullname
,
309 homedir_len
, homedir
,
310 dir_drive_len
, dir_drive
,
311 logon_script_len
, logon_script
,
312 profile_path_len
, profile_path
,
313 acct_desc_len
, acct_desc
,
314 workstations_len
, workstations
,
315 unknown_str_len
, unknown_str
,
316 munged_dial_len
, munged_dial
,
317 pdb_get_user_rid(sampass
),
318 pdb_get_group_rid(sampass
),
321 pdb_get_acct_ctrl(sampass
),
322 pdb_get_unknown3(sampass
),
323 pdb_get_logon_divs(sampass
),
324 pdb_get_hours_len(sampass
),
325 MAX_HOURS_LEN
, pdb_get_hours(sampass
),
326 pdb_get_unknown5(sampass
),
327 pdb_get_unknown6(sampass
));
330 /* check to make sure we got it correct */
341 /***************************************************************
342 Open the TDB passwd database for SAM account enumeration.
343 ****************************************************************/
344 BOOL
pdb_setsampwent(BOOL update
)
348 pstrcpy (tdbfile
, lp_private_dir());
349 pstrcat (tdbfile
, PASSDB_FILE_NAME
);
351 /* Open tdb passwd */
352 if (!(global_tdb_ent
.passwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, update
? O_RDWR
: O_RDONLY
, 0600)))
354 DEBUG(0, ("Unable to open TDB passwd, trying create new!\n"));
355 if (!(global_tdb_ent
.passwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDWR
| O_CREAT
| O_EXCL
, 0600)))
357 DEBUG(0, ("Unable to create TDB passwd (passdb.tdb) !!!"));
362 global_tdb_ent
.key
= tdb_firstkey(global_tdb_ent
.passwd_tdb
);
367 /***************************************************************
368 End enumeration of the TDB passwd list.
369 ****************************************************************/
370 void pdb_endsampwent(void)
372 if (global_tdb_ent
.passwd_tdb
)
374 tdb_close(global_tdb_ent
.passwd_tdb
);
375 global_tdb_ent
.passwd_tdb
= NULL
;
378 DEBUG(7, ("endtdbpwent: closed password file.\n"));
382 /*****************************************************************
383 Get one SAM_ACCOUNT from the TDB (next in line)
384 *****************************************************************/
385 BOOL
pdb_getsampwent(SAM_ACCOUNT
*user
)
391 char *prefix
= USERPREFIX
;
392 int prefixlen
= strlen (prefix
);
395 DEBUG(0,("pdb_get_sampwent: SAM_ACCOUNT is NULL.\n"));
399 /* skip all RID entries */
400 while ((global_tdb_ent
.key
.dsize
!= 0) && (strncmp (global_tdb_ent
.key
.dptr
, prefix
, prefixlen
)))
401 /* increment to next in line */
402 global_tdb_ent
.key
= tdb_nextkey (global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
404 /* do we have an valid interation pointer? */
405 if(global_tdb_ent
.passwd_tdb
== NULL
)
407 DEBUG(0,("pdb_get_sampwent: Bad TDB Context pointer.\n"));
411 data
= tdb_fetch (global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
414 DEBUG(5,("pdb_getsampwent: database entry not found.\n"));
418 /* unpack the buffer */
419 if (!init_sam_from_buffer (user
, data
.dptr
, data
.dsize
))
421 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
425 /* validate the account and fill in UNIX uid and gid. sys_getpwnam()
426 is used instaed of Get_Pwnam() as we do not need to try case
428 if ((pw
=sys_getpwnam(pdb_get_username(user
))) == NULL
)
430 DEBUG(0,("pdb_getsampwent: getpwnam(%s) return NULL. User does not exist!\n",
431 pdb_get_username(user
)));
437 pdb_set_uid (user
, uid
);
438 pdb_set_gid (user
, gid
);
440 /* 21 days from present */
441 pdb_set_pass_must_change_time(user
, time(NULL
)+1814400);
443 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_logon_script(user
));
444 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_profile_path(user
));
445 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_homedir(user
));
447 /* increment to next in line */
448 global_tdb_ent
.key
= tdb_nextkey (global_tdb_ent
.passwd_tdb
, global_tdb_ent
.key
);
453 /******************************************************************
454 Lookup a name in the SAM TDB
455 ******************************************************************/
456 BOOL
pdb_getsampwnam (SAM_ACCOUNT
*user
, char *sname
)
458 TDB_CONTEXT
*pwd_tdb
;
469 DEBUG(0,("pdb_getsampwnam: SAM_ACCOUNT is NULL.\n"));
473 fstrcpy (name
, sname
);
475 pstrcpy (tdbfile
, lp_private_dir());
476 pstrcat (tdbfile
, PASSDB_FILE_NAME
);
479 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
481 key
.dsize
= strlen (keystr
) + 1;
483 /* open the accounts TDB */
484 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDONLY
, 0600)))
486 DEBUG(0, ("pdb_getsampwnam: Unable to open TDB passwd!\n"));
491 data
= tdb_fetch (pwd_tdb
, key
);
494 DEBUG(5,("pdb_getsampwnam (TDB): error fetching database.\n"));
495 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
500 /* unpack the buffer */
501 if (!init_sam_from_buffer (user
, data
.dptr
, data
.dsize
))
503 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
507 /* validate the account and fill in UNIX uid and gid. sys_getpwnam()
508 is used instaed of Get_Pwnam() as we do not need to try case
510 if ((pw
=sys_getpwnam(pdb_get_username(user
))) == NULL
)
512 DEBUG(0,("pdb_getsampwent: getpwnam(%s) return NULL. User does not exist!\n",
513 pdb_get_username(user
)));
519 pdb_set_uid (user
, uid
);
520 pdb_set_gid (user
, gid
);
522 /* 21 days from present */
523 pdb_set_pass_must_change_time(user
, time(NULL
)+1814400);
525 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_logon_script(user
));
526 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_profile_path(user
));
527 standard_sub_advanced(-1, pdb_get_username(user
), "", gid
, pdb_get_homedir(user
));
535 /***************************************************************************
537 **************************************************************************/
538 BOOL
pdb_getsampwuid (SAM_ACCOUNT
* user
, uid_t uid
)
544 DEBUG(0,("pdb_getsampwuid: SAM_ACCOUNT is NULL.\n"));
548 pw
= sys_getpwuid(uid
);
551 DEBUG(0,("pdb_getsampwuid: getpwuid(%d) return NULL. User does not exist!\n", uid
));
554 fstrcpy (name
, pw
->pw_name
);
556 return pdb_getsampwnam (user
, name
);
560 /***************************************************************************
562 **************************************************************************/
563 BOOL
pdb_getsampwrid (SAM_ACCOUNT
*user
, uint32 rid
)
565 TDB_CONTEXT
*pwd_tdb
;
572 DEBUG(0,("pdb_getsampwrid: SAM_ACCOUNT is NULL.\n"));
576 pstrcpy (tdbfile
, lp_private_dir());
577 pstrcat (tdbfile
, PASSDB_FILE_NAME
);
580 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, rid
);
582 key
.dsize
= strlen (keystr
) + 1;
584 /* open the accounts TDB */
585 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDONLY
, 0600)))
587 DEBUG(0, ("pdb_getsampwrid: Unable to open TDB rid database!\n"));
592 data
= tdb_fetch (pwd_tdb
, key
);
595 DEBUG(5,("pdb_getsampwrid (TDB): error fetching database.\n"));
596 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
601 fstrcpy (name
, data
.dptr
);
605 return pdb_getsampwnam (user
, name
);
609 /***************************************************************************
611 ****************************************************************************/
612 BOOL
pdb_delete_sam_account(char *sname
)
614 struct passwd
*pwd
= NULL
;
615 SAM_ACCOUNT
*sam_pass
= NULL
;
616 TDB_CONTEXT
*pwd_tdb
;
623 fstrcpy (name
, sname
);
626 pstrcpy (tdbfile
, lp_private_dir());
627 pstrcat (tdbfile
, PASSDB_FILE_NAME
);
630 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDWR
, 0600)))
632 DEBUG(0, ("Unable to open TDB passwd!"));
636 /* set the search key */
637 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
639 key
.dsize
= strlen (keystr
) + 1;
642 data
= tdb_fetch (pwd_tdb
, key
);
645 DEBUG(5,("pdb_delete_sam_account (TDB): error fetching database.\n"));
646 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
651 /* unpack the buffer */
652 if (!pdb_init_sam (&sam_pass
))
658 if (!init_sam_from_buffer (sam_pass
, data
.dptr
, data
.dsize
))
660 DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
665 pwd
= sys_getpwnam(sam_pass
->username
);
667 pdb_free_sam (sam_pass
);
669 rid
= pdb_uid_to_user_rid (pwd
->pw_uid
);
671 /* it's outaa here! 8^) */
672 if (tdb_delete(pwd_tdb
, key
) != TDB_SUCCESS
)
674 DEBUG(5, ("Error deleting entry from tdb passwd database!\n"));
675 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
680 /* delete also the RID key */
682 /* set the search key */
683 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, rid
);
685 key
.dsize
= strlen (keystr
) + 1;
687 /* it's outaa here! 8^) */
688 if (tdb_delete(pwd_tdb
, key
) != TDB_SUCCESS
)
690 DEBUG(5, ("Error deleting entry from tdb rid database!\n"));
691 DEBUGADD(5, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
701 /***************************************************************************
703 ****************************************************************************/
704 static BOOL
tdb_update_sam(SAM_ACCOUNT
* newpwd
, BOOL override
, int flag
)
706 TDB_CONTEXT
*pwd_tdb
;
714 pstrcpy (tdbfile
, lp_private_dir());
715 pstrcat (tdbfile
, PASSDB_FILE_NAME
);
717 if ( (!newpwd
->uid
) || (!newpwd
->gid
) )
718 DEBUG (0,("tdb_update_sam: Storing a SAM_ACCOUNT for [%s] with uid %d and gid %d!\n",
719 newpwd
->username
, newpwd
->uid
, newpwd
->gid
));
721 /* if we don't have a RID, then generate one */
722 if (!newpwd
->user_rid
)
723 pdb_set_user_rid (newpwd
, pdb_uid_to_user_rid (newpwd
->uid
));
724 if (!newpwd
->group_rid
)
725 pdb_set_group_rid (newpwd
, pdb_gid_to_group_rid (newpwd
->gid
));
728 /* copy the SAM_ACCOUNT struct into a BYTE buffer for storage */
729 if ((data
.dsize
=init_buffer_from_sam (&buf
, newpwd
)) == -1)
731 DEBUG(0,("tdb_update_sam: ERROR - Unable to copy SAM_ACCOUNT info BYTE buffer!\n"));
736 fstrcpy (name
, pdb_get_username(newpwd
));
739 /* setup the USER index key */
740 slprintf(keystr
, sizeof(keystr
)-1, "%s%s", USERPREFIX
, name
);
742 key
.dsize
= strlen (keystr
) + 1;
744 /* invalidate the existing TDB iterator if it is open */
745 if (global_tdb_ent
.passwd_tdb
)
747 tdb_close(global_tdb_ent
.passwd_tdb
);
748 global_tdb_ent
.passwd_tdb
= NULL
;
751 /* open the account TDB passwd*/
752 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDWR
, 0600)))
754 DEBUG(0, ("tdb_update_sam: Unable to open TDB passwd!\n"));
755 if (flag
== TDB_INSERT
)
757 DEBUG(0, ("Unable to open TDB passwd, trying create new!\n"));
758 if (!(pwd_tdb
= tdb_open_log(tdbfile
, 0, USE_TDB_MMAP_FLAG
, O_RDWR
| O_CREAT
| O_EXCL
, 0600)))
760 DEBUG(0, ("Unable to create TDB passwd (passdb.tdb) !!!\n"));
767 /* add the account */
768 if (tdb_store(pwd_tdb
, key
, data
, flag
) != TDB_SUCCESS
)
770 DEBUG(0, ("Unable to modify passwd TDB!"));
771 DEBUGADD(0, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
777 data
.dsize
= sizeof(fstring
);
780 /* setup the RID index key */
781 slprintf(keystr
, sizeof(keystr
)-1, "%s%.8x", RIDPREFIX
, pdb_get_user_rid(newpwd
));
783 key
.dsize
= strlen (keystr
) + 1;
785 /* add the reference */
786 if (tdb_store(pwd_tdb
, key
, data
, flag
) != TDB_SUCCESS
)
788 DEBUG(0, ("Unable to modify TDB passwd !"));
789 DEBUGADD(0, (" Error: %s\n", tdb_errorstr(pwd_tdb
)));
800 /***************************************************************************
801 Modifies an existing SAM_ACCOUNT
802 ****************************************************************************/
803 BOOL
pdb_update_sam_account (SAM_ACCOUNT
*newpwd
, BOOL override
)
805 return (tdb_update_sam(newpwd
, override
, TDB_MODIFY
));
808 /***************************************************************************
809 Adds an existing SAM_ACCOUNT
810 ****************************************************************************/
811 BOOL
pdb_add_sam_account (SAM_ACCOUNT
*newpwd
)
813 return (tdb_update_sam(newpwd
, True
, TDB_INSERT
));
818 /* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
819 void samtdb_dummy_function(void) { } /* stop some compilers complaining */
820 #endif /* WITH_TDBPWD */