2 * Unix SMB/Netbios implementation.
4 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1999,
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
7 * Copyright (C) Matthew Chapman 1999,
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 extern int DEBUGLEVEL;
32 extern pstring global_myname;
34 BOOL synchronise_passdb(void)
37 SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
38 SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
41 SAM_ACCOUNT_INFO *acc;
42 struct smb_passwd pwd;
44 unsigned char smb_passwd[16];
45 unsigned char smb_nt_passwd[16];
46 uchar trust_passwd[16];
53 if (!cli_connect_serverlist(&cli, lp_passwordserver()))
58 if (!trust_get_passwd(trust_passwd, lp_workgroup(), global_myname))
63 ret = do_sam_sync(&cli, trust_passwd, cli.mach_acct, global_myname,
64 hdr_deltas, deltas, &num);
68 for (i = 0; i < num; i++)
70 /* Currently only interested in accounts */
71 if (hdr_deltas[i].type != 5)
76 acc = &deltas[i].account_info;
79 pwd.user_rid = acc->user_rid;
80 unistr2_to_ascii(nt_name, &(acc->uni_acct_name), sizeof(fstring)-1);
81 pwd.nt_name = nt_name;
82 pwd.acct_ctrl = acc->acb_info;
83 pwd.pass_last_set_time = nt_time_to_unix(&(acc->pwd_last_set_time));
85 sam_pwd_hash(acc->user_rid, smb_passwd, acc->pass.buf_lm_pwd, 0);
86 sam_pwd_hash(acc->user_rid, smb_nt_passwd, acc->pass.buf_nt_pwd, 0);
87 pwd.smb_passwd = smb_passwd;
88 pwd.smb_nt_passwd = smb_nt_passwd;
91 success = mod_smbpwd_entry(&pwd, True);
96 success = add_smbpwd_entry(&pwd);
99 DEBUG(0, ("Attempted to %s account for %s: %s\n", mode,
100 nt_name, success ? "OK" : "FAILED"));