diff options
author | Michael Adam <obnox@samba.org> | 2009-10-26 16:07:58 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-10-27 15:39:09 +0100 |
commit | 8fdef14305ae1e32d61c80cb10859d41c5754023 (patch) | |
tree | bc97a588ba745c43cc7e636b3e6931709ceae515 /source3 | |
parent | 798b05a9740f43b2b6f9a5091878d85e3c88409d (diff) | |
download | samba-8fdef14305ae1e32d61c80cb10859d41c5754023.tar.gz samba-8fdef14305ae1e32d61c80cb10859d41c5754023.tar.bz2 samba-8fdef14305ae1e32d61c80cb10859d41c5754023.zip |
s3: pdbedit: add option --kickoff-time/-K to set the user's kickoff time
Use "never" as argument to set this to unlimited.
Michael
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/pdbedit.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index dce2f05a83..5d8a6fd749 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -49,9 +49,10 @@ #define BIT_FIX_INIT 0x04000000 #define BIT_BADPWRESET 0x08000000 #define BIT_LOGONHOURS 0x10000000 +#define BIT_KICKOFFTIME 0x20000000 #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) { @@ -493,7 +494,8 @@ static int set_user_info(const char *username, const char *fullname, const char *drive, const char *script, const char *profile, const char *account_control, 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; 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); } + 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))) { print_user_info(username, True, False); } else { @@ -989,6 +1009,7 @@ int main (int argc, char **argv) static char *pwd_time_format = NULL; static int pw_from_stdin = False; struct pdb_methods *bin, *bout; + static char *kickoff_time = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; 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}, {"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}, + {"kickoff-time", 'K', POPT_ARG_STRING, &kickoff_time, 0, "set the kickoff time", NULL}, POPT_COMMON_SAMBA POPT_TABLEEND }; @@ -1083,7 +1105,8 @@ int main (int argc, char **argv) (backend_in ? BIT_IMPORT : 0) + (backend_out ? BIT_EXPORT : 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) { /* HACK: set the global passdb backend by overwriting globals. @@ -1279,7 +1302,8 @@ int main (int argc, char **argv) home_drive, logon_script, profile_path, account_control, user_sid, user_domain, - badpw_reset, hours_reset); + badpw_reset, hours_reset, + kickoff_time); } } } |