mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
s3: pdbedit: add option --kickoff-time/-K to set the user's kickoff time
Use "never" as argument to set this to unlimited. Michael
This commit is contained in:
parent
798b05a974
commit
8fdef14305
@ -49,9 +49,10 @@
|
|||||||
#define BIT_FIX_INIT 0x04000000
|
#define BIT_FIX_INIT 0x04000000
|
||||||
#define BIT_BADPWRESET 0x08000000
|
#define BIT_BADPWRESET 0x08000000
|
||||||
#define BIT_LOGONHOURS 0x10000000
|
#define BIT_LOGONHOURS 0x10000000
|
||||||
|
#define BIT_KICKOFFTIME 0x20000000
|
||||||
|
|
||||||
#define MASK_ALWAYS_GOOD 0x0000001F
|
#define MASK_ALWAYS_GOOD 0x0000001F
|
||||||
#define MASK_USER_GOOD 0x00405FE0
|
#define MASK_USER_GOOD 0x20405FE0
|
||||||
|
|
||||||
static int get_sid_from_cli_string(DOM_SID *sid, const char *str_sid)
|
static int get_sid_from_cli_string(DOM_SID *sid, const char *str_sid)
|
||||||
{
|
{
|
||||||
@ -493,7 +494,8 @@ static int set_user_info(const char *username, const char *fullname,
|
|||||||
const char *drive, const char *script,
|
const char *drive, const char *script,
|
||||||
const char *profile, const char *account_control,
|
const char *profile, const char *account_control,
|
||||||
const char *user_sid, const char *user_domain,
|
const char *user_sid, const char *user_domain,
|
||||||
const bool badpw, const bool hours)
|
const bool badpw, const bool hours,
|
||||||
|
const char *kickoff_time)
|
||||||
{
|
{
|
||||||
bool updated_autolock = False, updated_badpw = False;
|
bool updated_autolock = False, updated_badpw = False;
|
||||||
struct samu *sam_pwent;
|
struct samu *sam_pwent;
|
||||||
@ -578,6 +580,24 @@ static int set_user_info(const char *username, const char *fullname,
|
|||||||
pdb_set_bad_password_time(sam_pwent, 0, PDB_CHANGED);
|
pdb_set_bad_password_time(sam_pwent, 0, PDB_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kickoff_time) {
|
||||||
|
char *endptr;
|
||||||
|
time_t value = get_time_t_max();
|
||||||
|
|
||||||
|
if (strcmp(kickoff_time, "never") != 0) {
|
||||||
|
uint32_t num = strtoul(kickoff_time, &endptr, 10);
|
||||||
|
|
||||||
|
if ((endptr == kickoff_time) || (endptr[0] != '\0')) {
|
||||||
|
fprintf(stderr, "Failed to parse kickoff time\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
value = convert_uint32_to_time_t(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
pdb_set_kickoff_time(sam_pwent, value, PDB_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_STATUS_IS_OK(pdb_update_sam_account(sam_pwent))) {
|
if (NT_STATUS_IS_OK(pdb_update_sam_account(sam_pwent))) {
|
||||||
print_user_info(username, True, False);
|
print_user_info(username, True, False);
|
||||||
} else {
|
} else {
|
||||||
@ -989,6 +1009,7 @@ int main (int argc, char **argv)
|
|||||||
static char *pwd_time_format = NULL;
|
static char *pwd_time_format = NULL;
|
||||||
static int pw_from_stdin = False;
|
static int pw_from_stdin = False;
|
||||||
struct pdb_methods *bin, *bout;
|
struct pdb_methods *bin, *bout;
|
||||||
|
static char *kickoff_time = NULL;
|
||||||
TALLOC_CTX *frame = talloc_stackframe();
|
TALLOC_CTX *frame = talloc_stackframe();
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
poptContext pc;
|
poptContext pc;
|
||||||
@ -1025,6 +1046,7 @@ int main (int argc, char **argv)
|
|||||||
{"logon-hours-reset", 'Z', POPT_ARG_NONE, &hours_reset, 0, "reset logon hours", NULL},
|
{"logon-hours-reset", 'Z', POPT_ARG_NONE, &hours_reset, 0, "reset logon hours", NULL},
|
||||||
{"time-format", 0, POPT_ARG_STRING, &pwd_time_format, 0, "The time format for time parameters", NULL },
|
{"time-format", 0, POPT_ARG_STRING, &pwd_time_format, 0, "The time format for time parameters", NULL },
|
||||||
{"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL},
|
{"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL},
|
||||||
|
{"kickoff-time", 'K', POPT_ARG_STRING, &kickoff_time, 0, "set the kickoff time", NULL},
|
||||||
POPT_COMMON_SAMBA
|
POPT_COMMON_SAMBA
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
@ -1083,7 +1105,8 @@ int main (int argc, char **argv)
|
|||||||
(backend_in ? BIT_IMPORT : 0) +
|
(backend_in ? BIT_IMPORT : 0) +
|
||||||
(backend_out ? BIT_EXPORT : 0) +
|
(backend_out ? BIT_EXPORT : 0) +
|
||||||
(badpw_reset ? BIT_BADPWRESET : 0) +
|
(badpw_reset ? BIT_BADPWRESET : 0) +
|
||||||
(hours_reset ? BIT_LOGONHOURS : 0);
|
(hours_reset ? BIT_LOGONHOURS : 0) +
|
||||||
|
(kickoff_time ? BIT_KICKOFFTIME : 0);
|
||||||
|
|
||||||
if (setparms & BIT_BACKEND) {
|
if (setparms & BIT_BACKEND) {
|
||||||
/* HACK: set the global passdb backend by overwriting globals.
|
/* HACK: set the global passdb backend by overwriting globals.
|
||||||
@ -1279,7 +1302,8 @@ int main (int argc, char **argv)
|
|||||||
home_drive, logon_script,
|
home_drive, logon_script,
|
||||||
profile_path, account_control,
|
profile_path, account_control,
|
||||||
user_sid, user_domain,
|
user_sid, user_domain,
|
||||||
badpw_reset, hours_reset);
|
badpw_reset, hours_reset,
|
||||||
|
kickoff_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user