37
37
#define PDB_NOT_QUITE_NULL ""
39
39
/*********************************************************************
40
Collection of get...() functions for SAM_ACCOUNT.
40
Collection of get...() functions for struct samu.
41
41
********************************************************************/
43
uint16 pdb_get_acct_ctrl (const SAM_ACCOUNT *sampass)
46
return (sampass->private_u.acct_ctrl);
48
return (ACB_DISABLED);
51
time_t pdb_get_logon_time (const SAM_ACCOUNT *sampass)
54
return (sampass->private_u.logon_time);
59
time_t pdb_get_logoff_time (const SAM_ACCOUNT *sampass)
62
return (sampass->private_u.logoff_time);
67
time_t pdb_get_kickoff_time (const SAM_ACCOUNT *sampass)
70
return (sampass->private_u.kickoff_time);
75
time_t pdb_get_bad_password_time (const SAM_ACCOUNT *sampass)
78
return (sampass->private_u.bad_password_time);
83
time_t pdb_get_pass_last_set_time (const SAM_ACCOUNT *sampass)
86
return (sampass->private_u.pass_last_set_time);
91
time_t pdb_get_pass_can_change_time (const SAM_ACCOUNT *sampass)
94
return (sampass->private_u.pass_can_change_time);
99
time_t pdb_get_pass_must_change_time (const SAM_ACCOUNT *sampass)
102
return (sampass->private_u.pass_must_change_time);
107
uint16 pdb_get_logon_divs (const SAM_ACCOUNT *sampass)
110
return (sampass->private_u.logon_divs);
115
uint32 pdb_get_hours_len (const SAM_ACCOUNT *sampass)
118
return (sampass->private_u.hours_len);
123
const uint8* pdb_get_hours (const SAM_ACCOUNT *sampass)
126
return (sampass->private_u.hours);
131
const uint8* pdb_get_nt_passwd (const SAM_ACCOUNT *sampass)
134
SMB_ASSERT((!sampass->private_u.nt_pw.data)
135
|| sampass->private_u.nt_pw.length == NT_HASH_LEN);
136
return ((uint8*)sampass->private_u.nt_pw.data);
142
const uint8* pdb_get_lanman_passwd (const SAM_ACCOUNT *sampass)
145
SMB_ASSERT((!sampass->private_u.lm_pw.data)
146
|| sampass->private_u.lm_pw.length == LM_HASH_LEN);
147
return ((uint8*)sampass->private_u.lm_pw.data);
153
const uint8* pdb_get_pw_history (const SAM_ACCOUNT *sampass, uint32 *current_hist_len)
156
SMB_ASSERT((!sampass->private_u.nt_pw_his.data)
157
|| ((sampass->private_u.nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
158
*current_hist_len = sampass->private_u.nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
159
return ((uint8*)sampass->private_u.nt_pw_his.data);
161
*current_hist_len = 0;
43
uint32 pdb_get_acct_ctrl(const struct samu *sampass)
45
return sampass->acct_ctrl;
48
time_t pdb_get_logon_time(const struct samu *sampass)
50
return sampass->logon_time;
53
time_t pdb_get_logoff_time(const struct samu *sampass)
55
return sampass->logoff_time;
58
time_t pdb_get_kickoff_time(const struct samu *sampass)
60
return sampass->kickoff_time;
63
time_t pdb_get_bad_password_time(const struct samu *sampass)
65
return sampass->bad_password_time;
68
time_t pdb_get_pass_last_set_time(const struct samu *sampass)
70
return sampass->pass_last_set_time;
73
time_t pdb_get_pass_can_change_time(const struct samu *sampass)
75
return sampass->pass_can_change_time;
78
time_t pdb_get_pass_must_change_time(const struct samu *sampass)
80
return sampass->pass_must_change_time;
83
uint16 pdb_get_logon_divs(const struct samu *sampass)
85
return sampass->logon_divs;
88
uint32 pdb_get_hours_len(const struct samu *sampass)
90
return sampass->hours_len;
93
const uint8 *pdb_get_hours(const struct samu *sampass)
95
return (sampass->hours);
98
const uint8 *pdb_get_nt_passwd(const struct samu *sampass)
100
SMB_ASSERT((!sampass->nt_pw.data)
101
|| sampass->nt_pw.length == NT_HASH_LEN);
102
return (uint8 *)sampass->nt_pw.data;
105
const uint8 *pdb_get_lanman_passwd(const struct samu *sampass)
107
SMB_ASSERT((!sampass->lm_pw.data)
108
|| sampass->lm_pw.length == LM_HASH_LEN);
109
return (uint8 *)sampass->lm_pw.data;
112
const uint8 *pdb_get_pw_history(const struct samu *sampass, uint32 *current_hist_len)
114
SMB_ASSERT((!sampass->nt_pw_his.data)
115
|| ((sampass->nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
116
*current_hist_len = sampass->nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
117
return (uint8 *)sampass->nt_pw_his.data;
166
120
/* Return the plaintext password if known. Most of the time
169
123
Used to pass the plaintext to passdb backends that might
170
124
want to store more than just the NTLM hashes.
172
const char* pdb_get_plaintext_passwd (const SAM_ACCOUNT *sampass)
175
return (sampass->private_u.plaintext_pw);
180
const DOM_SID *pdb_get_user_sid(const SAM_ACCOUNT *sampass)
183
return &sampass->private_u.user_sid;
188
const DOM_SID *pdb_get_group_sid(const SAM_ACCOUNT *sampass)
191
return &sampass->private_u.group_sid;
126
const char *pdb_get_plaintext_passwd(const struct samu *sampass)
128
return sampass->plaintext_pw;
131
const DOM_SID *pdb_get_user_sid(const struct samu *sampass)
133
return &sampass->user_sid;
136
const DOM_SID *pdb_get_group_sid(struct samu *sampass)
141
/* Return the cached group SID if we have that */
142
if ( sampass->group_sid ) {
143
return sampass->group_sid;
146
/* generate the group SID from the user's primary Unix group */
148
if ( !(gsid = TALLOC_P( sampass, DOM_SID )) ) {
152
/* No algorithmic mapping, meaning that we have to figure out the
153
primary group SID according to group mapping and the user SID must
154
be a newly allocated one. We rely on the user's Unix primary gid.
155
We have no choice but to fail if we can't find it. */
157
if ( sampass->unix_pw ) {
158
pwd = sampass->unix_pw;
160
pwd = Get_Pwnam_alloc( sampass, pdb_get_username(sampass) );
164
DEBUG(0,("pdb_get_group_sid: Failed to find Unix account for %s\n", pdb_get_username(sampass) ));
168
if ( pdb_gid_to_sid(pwd->pw_gid, gsid) ) {
169
enum SID_NAME_USE type = SID_NAME_UNKNOWN;
170
TALLOC_CTX *mem_ctx = talloc_init("pdb_get_group_sid");
177
/* Now check that it's actually a domain group and not something else */
179
lookup_ret = lookup_sid(mem_ctx, gsid, NULL, NULL, &type);
181
TALLOC_FREE( mem_ctx );
183
if ( lookup_ret && (type == SID_NAME_DOM_GRP) ) {
184
sampass->group_sid = gsid;
185
return sampass->group_sid;
188
DEBUG(3, ("Primary group for user %s is a %s and not a domain group\n",
189
pwd->pw_name, sid_type_lookup(type)));
192
/* Just set it to the 'Domain Users' RID of 512 which will
193
always resolve to a name */
195
sid_copy( gsid, get_global_sam_sid() );
196
sid_append_rid( gsid, DOMAIN_GROUP_RID_USERS );
198
sampass->group_sid = gsid;
200
return sampass->group_sid;
197
* Get flags showing what is initalised in the SAM_ACCOUNT
198
* @param sampass the SAM_ACCOUNT in question
204
* Get flags showing what is initalised in the struct samu
205
* @param sampass the struct samu in question
199
206
* @return the flags indicating the members initialised in the struct.
202
enum pdb_value_state pdb_get_init_flags (const SAM_ACCOUNT *sampass, enum pdb_elements element)
209
enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element)
204
211
enum pdb_value_state ret = PDB_DEFAULT;
206
if (!sampass || !sampass->private_u.change_flags || !sampass->private_u.set_flags)
213
if (!sampass->change_flags || !sampass->set_flags)
209
if (bitmap_query(sampass->private_u.set_flags, element)) {
216
if (bitmap_query(sampass->set_flags, element)) {
210
217
DEBUG(11, ("element %d: SET\n", element));
214
if (bitmap_query(sampass->private_u.change_flags, element)) {
221
if (bitmap_query(sampass->change_flags, element)) {
215
222
DEBUG(11, ("element %d: CHANGED\n", element));
216
223
ret = PDB_CHANGED;
226
const char* pdb_get_username (const SAM_ACCOUNT *sampass)
229
return (sampass->private_u.username);
234
const char* pdb_get_domain (const SAM_ACCOUNT *sampass)
237
return (sampass->private_u.domain);
242
const char* pdb_get_nt_username (const SAM_ACCOUNT *sampass)
245
return (sampass->private_u.nt_username);
250
const char* pdb_get_fullname (const SAM_ACCOUNT *sampass)
253
return (sampass->private_u.full_name);
258
const char* pdb_get_homedir (const SAM_ACCOUNT *sampass)
261
return (sampass->private_u.home_dir);
266
const char* pdb_get_unix_homedir (const SAM_ACCOUNT *sampass)
269
return (sampass->private_u.unix_home_dir);
274
const char* pdb_get_dir_drive (const SAM_ACCOUNT *sampass)
277
return (sampass->private_u.dir_drive);
282
const char* pdb_get_logon_script (const SAM_ACCOUNT *sampass)
285
return (sampass->private_u.logon_script);
290
const char* pdb_get_profile_path (const SAM_ACCOUNT *sampass)
293
return (sampass->private_u.profile_path);
298
const char* pdb_get_acct_desc (const SAM_ACCOUNT *sampass)
301
return (sampass->private_u.acct_desc);
306
const char* pdb_get_workstations (const SAM_ACCOUNT *sampass)
309
return (sampass->private_u.workstations);
314
const char* pdb_get_unknown_str (const SAM_ACCOUNT *sampass)
317
return (sampass->private_u.unknown_str);
322
const char* pdb_get_munged_dial (const SAM_ACCOUNT *sampass)
325
return (sampass->private_u.munged_dial);
330
uint16 pdb_get_bad_password_count(const SAM_ACCOUNT *sampass)
333
return (sampass->private_u.bad_password_count);
338
uint16 pdb_get_logon_count(const SAM_ACCOUNT *sampass)
341
return (sampass->private_u.logon_count);
346
uint32 pdb_get_unknown_6 (const SAM_ACCOUNT *sampass)
349
return (sampass->private_u.unknown_6);
354
void *pdb_get_backend_private_data (const SAM_ACCOUNT *sampass, const struct pdb_methods *my_methods)
356
if (sampass && my_methods == sampass->private_u.backend_private_methods)
357
return sampass->private_u.backend_private_data;
233
const char *pdb_get_username(const struct samu *sampass)
235
return sampass->username;
238
const char *pdb_get_domain(const struct samu *sampass)
240
return sampass->domain;
243
const char *pdb_get_nt_username(const struct samu *sampass)
245
return sampass->nt_username;
248
const char *pdb_get_fullname(const struct samu *sampass)
250
return sampass->full_name;
253
const char *pdb_get_homedir(const struct samu *sampass)
255
return sampass->home_dir;
258
const char *pdb_get_unix_homedir(const struct samu *sampass)
260
if (sampass->unix_pw ) {
261
return sampass->unix_pw->pw_dir;
266
const char *pdb_get_dir_drive(const struct samu *sampass)
268
return sampass->dir_drive;
271
const char *pdb_get_logon_script(const struct samu *sampass)
273
return sampass->logon_script;
276
const char *pdb_get_profile_path(const struct samu *sampass)
278
return sampass->profile_path;
281
const char *pdb_get_acct_desc(const struct samu *sampass)
283
return sampass->acct_desc;
286
const char *pdb_get_workstations(const struct samu *sampass)
288
return sampass->workstations;
291
const char *pdb_get_unknown_str(const struct samu *sampass)
293
return sampass->unknown_str;
296
const char *pdb_get_munged_dial(const struct samu *sampass)
298
return sampass->munged_dial;
301
uint16 pdb_get_bad_password_count(const struct samu *sampass)
303
return sampass->bad_password_count;
306
uint16 pdb_get_logon_count(const struct samu *sampass)
308
return sampass->logon_count;
311
uint32 pdb_get_unknown_6(const struct samu *sampass)
313
return sampass->unknown_6;
316
void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods)
318
if (my_methods == sampass->backend_private_methods) {
319
return sampass->backend_private_data;
362
325
/*********************************************************************
363
Collection of set...() functions for SAM_ACCOUNT.
326
Collection of set...() functions for struct samu.
364
327
********************************************************************/
366
BOOL pdb_set_acct_ctrl (SAM_ACCOUNT *sampass, uint16 acct_ctrl, enum pdb_value_state flag)
329
BOOL pdb_set_acct_ctrl(struct samu *sampass, uint32 acct_ctrl, enum pdb_value_state flag)
371
sampass->private_u.acct_ctrl = acct_ctrl;
331
sampass->acct_ctrl = acct_ctrl;
373
332
return pdb_set_init_flags(sampass, PDB_ACCTCTRL, flag);
376
BOOL pdb_set_logon_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
335
BOOL pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
381
sampass->private_u.logon_time = mytime;
337
sampass->logon_time = mytime;
383
338
return pdb_set_init_flags(sampass, PDB_LOGONTIME, flag);
386
BOOL pdb_set_logoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
341
BOOL pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
391
sampass->private_u.logoff_time = mytime;
343
sampass->logoff_time = mytime;
393
344
return pdb_set_init_flags(sampass, PDB_LOGOFFTIME, flag);
396
BOOL pdb_set_kickoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
347
BOOL pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
401
sampass->private_u.kickoff_time = mytime;
349
sampass->kickoff_time = mytime;
403
350
return pdb_set_init_flags(sampass, PDB_KICKOFFTIME, flag);
406
BOOL pdb_set_bad_password_time (SAM_ACCOUNT *sampass, time_t mytime,
407
enum pdb_value_state flag)
353
BOOL pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
412
sampass->private_u.bad_password_time = mytime;
355
sampass->bad_password_time = mytime;
414
356
return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_TIME, flag);
417
BOOL pdb_set_pass_can_change_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
359
BOOL pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
422
sampass->private_u.pass_can_change_time = mytime;
361
sampass->pass_can_change_time = mytime;
424
362
return pdb_set_init_flags(sampass, PDB_CANCHANGETIME, flag);
427
BOOL pdb_set_pass_must_change_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
365
BOOL pdb_set_pass_must_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
432
sampass->private_u.pass_must_change_time = mytime;
367
sampass->pass_must_change_time = mytime;
434
368
return pdb_set_init_flags(sampass, PDB_MUSTCHANGETIME, flag);
437
BOOL pdb_set_pass_last_set_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
371
BOOL pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
442
sampass->private_u.pass_last_set_time = mytime;
373
sampass->pass_last_set_time = mytime;
444
374
return pdb_set_init_flags(sampass, PDB_PASSLASTSET, flag);
447
BOOL pdb_set_hours_len (SAM_ACCOUNT *sampass, uint32 len, enum pdb_value_state flag)
377
BOOL pdb_set_hours_len(struct samu *sampass, uint32 len, enum pdb_value_state flag)
452
sampass->private_u.hours_len = len;
379
sampass->hours_len = len;
454
380
return pdb_set_init_flags(sampass, PDB_HOURSLEN, flag);
457
BOOL pdb_set_logon_divs (SAM_ACCOUNT *sampass, uint16 hours, enum pdb_value_state flag)
383
BOOL pdb_set_logon_divs(struct samu *sampass, uint16 hours, enum pdb_value_state flag)
462
sampass->private_u.logon_divs = hours;
385
sampass->logon_divs = hours;
464
386
return pdb_set_init_flags(sampass, PDB_LOGONDIVS, flag);
468
* Set flags showing what is initalised in the SAM_ACCOUNT
469
* @param sampass the SAM_ACCOUNT in question
390
* Set flags showing what is initalised in the struct samu
391
* @param sampass the struct samu in question
470
392
* @param flag The *new* flag to be set. Old flags preserved
471
393
* this flag is only added.
474
BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
396
BOOL pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
476
if (!sampass || !sampass->mem_ctx)
479
if (!sampass->private_u.set_flags) {
480
if ((sampass->private_u.set_flags =
481
bitmap_talloc(sampass->mem_ctx,
398
if (!sampass->set_flags) {
399
if ((sampass->set_flags =
400
bitmap_talloc(sampass,
482
401
PDB_COUNT))==NULL) {
483
402
DEBUG(0,("bitmap_talloc failed\n"));
487
if (!sampass->private_u.change_flags) {
488
if ((sampass->private_u.change_flags =
489
bitmap_talloc(sampass->mem_ctx,
406
if (!sampass->change_flags) {
407
if ((sampass->change_flags =
408
bitmap_talloc(sampass,
490
409
PDB_COUNT))==NULL) {
491
410
DEBUG(0,("bitmap_talloc failed\n"));
564
483
if (!pdb_set_user_sid(sampass, &new_sid, flag)) {
565
DEBUG(1, ("pdb_set_user_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", u_sid));
484
DEBUG(1, ("pdb_set_user_sid_from_string: could not set sid %s on struct samu!\n", u_sid));
572
BOOL pdb_set_group_sid (SAM_ACCOUNT *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
491
/********************************************************************
492
We never fill this in from a passdb backend but rather set is
493
based on the user's primary group membership. However, the
494
struct samu* is overloaded and reused in domain memship code
495
as well and built from the NET_USER_INFO_3 or PAC so we
496
have to allow the explicitly setting of a group SID here.
497
********************************************************************/
499
BOOL pdb_set_group_sid(struct samu *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
574
if (!sampass || !g_sid)
577
sid_copy(&sampass->private_u.group_sid, g_sid);
506
if ( !(sampass->group_sid = TALLOC_P( sampass, DOM_SID )) ) {
510
/* if we cannot resolve the SID to gid, then just ignore it and
511
store DOMAIN_USERS as the primary groupSID */
513
if ( sid_to_gid( g_sid, &gid ) ) {
514
sid_copy(sampass->group_sid, g_sid);
516
sid_copy( sampass->group_sid, get_global_sam_sid() );
517
sid_append_rid( sampass->group_sid, DOMAIN_GROUP_RID_USERS );
579
520
DEBUG(10, ("pdb_set_group_sid: setting group sid %s\n",
580
sid_string_static(&sampass->private_u.group_sid)));
521
sid_string_static(sampass->group_sid)));
582
523
return pdb_set_init_flags(sampass, PDB_GROUPSID, flag);
585
BOOL pdb_set_group_sid_from_string (SAM_ACCOUNT *sampass, fstring g_sid, enum pdb_value_state flag)
588
if (!sampass || !g_sid)
591
DEBUG(10, ("pdb_set_group_sid_from_string: setting group sid %s\n",
594
if (!string_to_sid(&new_sid, g_sid)) {
595
DEBUG(1, ("pdb_set_group_sid_from_string: %s isn't a valid SID!\n", g_sid));
599
if (!pdb_set_group_sid(sampass, &new_sid, flag)) {
600
DEBUG(1, ("pdb_set_group_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", g_sid));
606
526
/*********************************************************************
607
527
Set the user's UNIX name.
608
528
********************************************************************/
610
BOOL pdb_set_username(SAM_ACCOUNT *sampass, const char *username, enum pdb_value_state flag)
530
BOOL pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag)
616
533
DEBUG(10, ("pdb_set_username: setting username %s, was %s\n", username,
617
(sampass->private_u.username)?(sampass->private_u.username):"NULL"));
619
sampass->private_u.username = talloc_strdup(sampass->mem_ctx, username);
621
if (!sampass->private_u.username) {
534
(sampass->username)?(sampass->username):"NULL"));
536
sampass->username = talloc_strdup(sampass, username);
538
if (!sampass->username) {
622
539
DEBUG(0, ("pdb_set_username: talloc_strdup() failed!\n"));
627
sampass->private_u.username = PDB_NOT_QUITE_NULL;
543
sampass->username = PDB_NOT_QUITE_NULL;
630
546
return pdb_set_init_flags(sampass, PDB_USERNAME, flag);
796
689
Set the user's home directory.
797
690
********************************************************************/
799
BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *home_dir, enum pdb_value_state flag)
692
BOOL pdb_set_homedir(struct samu *sampass, const char *home_dir, enum pdb_value_state flag)
805
695
DEBUG(10, ("pdb_set_homedir: setting home dir %s, was %s\n", home_dir,
806
(sampass->private_u.home_dir)?(sampass->private_u.home_dir):"NULL"));
696
(sampass->home_dir)?(sampass->home_dir):"NULL"));
808
sampass->private_u.home_dir = talloc_strdup(sampass->mem_ctx, home_dir);
698
sampass->home_dir = talloc_strdup(sampass, home_dir);
810
if (!sampass->private_u.home_dir) {
700
if (!sampass->home_dir) {
811
701
DEBUG(0, ("pdb_set_home_dir: talloc_strdup() failed!\n"));
816
sampass->private_u.home_dir = PDB_NOT_QUITE_NULL;
705
sampass->home_dir = PDB_NOT_QUITE_NULL;
819
708
return pdb_set_init_flags(sampass, PDB_SMBHOME, flag);
822
711
/*********************************************************************
823
Set the user's unix home directory.
824
********************************************************************/
826
BOOL pdb_set_unix_homedir (SAM_ACCOUNT *sampass, const char *unix_home_dir, enum pdb_value_state flag)
832
DEBUG(10, ("pdb_set_unix_homedir: setting home dir %s, was %s\n", unix_home_dir,
833
(sampass->private_u.unix_home_dir)?(sampass->private_u.unix_home_dir):"NULL"));
835
sampass->private_u.unix_home_dir = talloc_strdup(sampass->mem_ctx,
838
if (!sampass->private_u.unix_home_dir) {
839
DEBUG(0, ("pdb_set_unix_home_dir: talloc_strdup() failed!\n"));
844
sampass->private_u.unix_home_dir = PDB_NOT_QUITE_NULL;
847
return pdb_set_init_flags(sampass, PDB_UNIXHOMEDIR, flag);
850
/*********************************************************************
851
712
Set the user's account description.
852
713
********************************************************************/
854
BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, const char *acct_desc, enum pdb_value_state flag)
715
BOOL pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_value_state flag)
860
sampass->private_u.acct_desc = talloc_strdup(sampass->mem_ctx, acct_desc);
718
sampass->acct_desc = talloc_strdup(sampass, acct_desc);
862
if (!sampass->private_u.acct_desc) {
720
if (!sampass->acct_desc) {
863
721
DEBUG(0, ("pdb_set_acct_desc: talloc_strdup() failed!\n"));
868
sampass->private_u.acct_desc = PDB_NOT_QUITE_NULL;
725
sampass->acct_desc = PDB_NOT_QUITE_NULL;
871
728
return pdb_set_init_flags(sampass, PDB_ACCTDESC, flag);
1018
857
********************************************************************/
1020
BOOL pdb_set_plaintext_pw_only (SAM_ACCOUNT *sampass, const char *password, enum pdb_value_state flag)
859
BOOL pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag)
1026
if (sampass->private_u.plaintext_pw!=NULL)
1027
memset(sampass->private_u.plaintext_pw,'\0',strlen(sampass->private_u.plaintext_pw)+1);
862
if (sampass->plaintext_pw!=NULL)
863
memset(sampass->plaintext_pw,'\0',strlen(sampass->plaintext_pw)+1);
1029
sampass->private_u.plaintext_pw = talloc_strdup(sampass->mem_ctx, password);
865
sampass->plaintext_pw = talloc_strdup(sampass, password);
1031
if (!sampass->private_u.plaintext_pw) {
867
if (!sampass->plaintext_pw) {
1032
868
DEBUG(0, ("pdb_set_unknown_str: talloc_strdup() failed!\n"));
1037
sampass->private_u.plaintext_pw = NULL;
872
sampass->plaintext_pw = NULL;
1040
875
return pdb_set_init_flags(sampass, PDB_PLAINTEXT_PW, flag);
1043
BOOL pdb_set_bad_password_count(SAM_ACCOUNT *sampass, uint16 bad_password_count, enum pdb_value_state flag)
878
BOOL pdb_set_bad_password_count(struct samu *sampass, uint16 bad_password_count, enum pdb_value_state flag)
1048
sampass->private_u.bad_password_count = bad_password_count;
880
sampass->bad_password_count = bad_password_count;
1050
881
return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_COUNT, flag);
1053
BOOL pdb_set_logon_count(SAM_ACCOUNT *sampass, uint16 logon_count, enum pdb_value_state flag)
884
BOOL pdb_set_logon_count(struct samu *sampass, uint16 logon_count, enum pdb_value_state flag)
1058
sampass->private_u.logon_count = logon_count;
886
sampass->logon_count = logon_count;
1060
887
return pdb_set_init_flags(sampass, PDB_LOGON_COUNT, flag);
1063
BOOL pdb_set_unknown_6 (SAM_ACCOUNT *sampass, uint32 unkn, enum pdb_value_state flag)
890
BOOL pdb_set_unknown_6(struct samu *sampass, uint32 unkn, enum pdb_value_state flag)
1068
sampass->private_u.unknown_6 = unkn;
892
sampass->unknown_6 = unkn;
1070
893
return pdb_set_init_flags(sampass, PDB_UNKNOWN6, flag);
1073
BOOL pdb_set_hours (SAM_ACCOUNT *sampass, const uint8 *hours, enum pdb_value_state flag)
896
BOOL pdb_set_hours(struct samu *sampass, const uint8 *hours, enum pdb_value_state flag)
1079
memset ((char *)sampass->private_u.hours, 0, MAX_HOURS_LEN);
899
memset ((char *)sampass->hours, 0, MAX_HOURS_LEN);
901
memcpy (sampass->hours, hours, MAX_HOURS_LEN);
1083
memcpy (sampass->private_u.hours, hours, MAX_HOURS_LEN);
1085
904
return pdb_set_init_flags(sampass, PDB_HOURS, flag);
1088
BOOL pdb_set_backend_private_data (SAM_ACCOUNT *sampass, void *private_data,
907
BOOL pdb_set_backend_private_data(struct samu *sampass, void *private_data,
1089
908
void (*free_fn)(void **),
1090
909
const struct pdb_methods *my_methods,
1091
910
enum pdb_value_state flag)
1096
if (sampass->private_u.backend_private_data && sampass->private_u.backend_private_data_free_fn) {
1097
sampass->private_u.backend_private_data_free_fn(&sampass->private_u.backend_private_data);
912
if (sampass->backend_private_data &&
913
sampass->backend_private_data_free_fn) {
914
sampass->backend_private_data_free_fn(
915
&sampass->backend_private_data);
1100
sampass->private_u.backend_private_data = private_data;
1101
sampass->private_u.backend_private_data_free_fn = free_fn;
1102
sampass->private_u.backend_private_methods = my_methods;
918
sampass->backend_private_data = private_data;
919
sampass->backend_private_data_free_fn = free_fn;
920
sampass->backend_private_methods = my_methods;
1104
922
return pdb_set_init_flags(sampass, PDB_BACKEND_PRIVATE_DATA, flag);