*/
#include "includes.h"
+#include "popt_common.h"
+#include "../librpc/gen_ndr/samr.h"
+#include "../libcli/security/security.h"
+#include "passdb.h"
#define BIT_BACKEND 0x00000004
#define BIT_VERBOSE 0x00000008
#define BIT_FIX_INIT 0x04000000
#define BIT_BADPWRESET 0x08000000
#define BIT_LOGONHOURS 0x10000000
+#define BIT_KICKOFFTIME 0x20000000
+#define BIT_DESCRIPTION 0x40000000
#define MASK_ALWAYS_GOOD 0x0000001F
-#define MASK_USER_GOOD 0x00405FE0
+#define MASK_USER_GOOD 0x60405FE0
-static int get_sid_from_cli_string(DOM_SID *sid, const char *str_sid)
+static int get_sid_from_cli_string(struct dom_sid *sid, const char *str_sid)
{
uint32_t rid;
"a complete SID or RID!\n");
return -1;
}
- sid_copy(sid, get_global_sam_sid());
- sid_append_rid(sid, rid);
+ sid_compose(sid, get_global_sam_sid(), rid);
}
return 0;
while (u_search->next_entry(u_search, &userentry)) {
struct samu *user;
struct samu *account;
- DOM_SID user_sid;
+ struct dom_sid user_sid;
DEBUG(4, ("Processing account %s\n", userentry.account_name));
int i;
for (i=1; decode_account_policy_name(i) != NULL; i++) {
- uint32 policy_value;
+ uint32_t policy_value;
if (!account_policy_get_default(i, &policy_value)) {
fprintf(stderr, "Can't get default account policy\n");
return -1;
int i;
for ( i=1; decode_account_policy_name(i) != NULL; i++ ) {
- uint32 policy_value;
+ uint32_t policy_value;
NTSTATUS status;
status = in->get_account_policy(in, i, &policy_value);
if (verbosity) {
char temp[44];
- const uint8 *hours;
+ const uint8_t *hours;
printf ("Unix username: %s\n", pdb_get_username(sam_pwent));
printf ("NT username: %s\n", pdb_get_nt_username(sam_pwent));
lm_passwd,
nt_passwd,
pdb_encode_acct_ctrl(pdb_get_acct_ctrl(sam_pwent),NEW_PW_FORMAT_SPACE_PADDED_LEN),
- (uint32)convert_time_t_to_uint32(pdb_get_pass_last_set_time(sam_pwent)));
+ (uint32)convert_time_t_to_uint32_t(pdb_get_pass_last_set_time(sam_pwent)));
} else {
uid = nametouid(pdb_get_username(sam_pwent));
printf ("%s:%lu:%s\n", pdb_get_username(sam_pwent), (unsigned long)uid,
struct samr_displayentry userentry;
struct samu *sam_pwent;
TALLOC_CTX *tosctx;
- DOM_SID user_sid;
+ struct dom_sid user_sid;
bool bret;
int ret;
struct samr_displayentry userentry;
struct samu *sam_pwent;
TALLOC_CTX *tosctx;
- DOM_SID user_sid;
+ struct dom_sid user_sid;
NTSTATUS status;
bool bret;
int ret;
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;
uint32_t acb_flags;
uint32_t not_settable;
uint32_t new_flags;
- DOM_SID u_sid;
+ struct dom_sid u_sid;
bool ret;
sam_pwent = samu_new(NULL);
hours_len = pdb_get_hours_len(sam_pwent);
memset(hours_array, 0xff, hours_len);
- pdb_set_hours(sam_pwent, hours_array, PDB_CHANGED);
+ pdb_set_hours(sam_pwent, hours_array, hours_len, PDB_CHANGED);
}
if (!pdb_update_autolock_flag(sam_pwent, &updated_autolock)) {
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_t_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 {
uint32_t acb_flags;
uint32_t not_settable;
uint32_t new_flags;
- DOM_SID m_sid;
+ struct dom_sid m_sid;
char *name;
int len;
bool ret;
struct samu *sam_pwent = NULL;
TALLOC_CTX *tosctx;
NTSTATUS status;
- DOM_SID u_sid;
+ struct dom_sid u_sid;
int flags;
int ret;
struct samu *sam_pwent = NULL;
TALLOC_CTX *tosctx;
NTSTATUS status;
- DOM_SID m_sid;
+ struct dom_sid m_sid;
char *compatpwd;
char *name;
int flags;
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;
{"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
};
load_case_tables();
- setup_logging("pdbedit", True);
+ setup_logging("pdbedit", DEBUG_STDOUT);
pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
(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) +
+ (acct_desc ? BIT_DESCRIPTION : 0);
if (setparms & BIT_BACKEND) {
/* HACK: set the global passdb backend by overwriting globals.
* This way we can use regular pdb functions for default
* operations that do not involve passdb migrations */
- lp_set_passdb_backend(backend);
+ lp_set_cmdline("passdb backend", backend);
} else {
backend = lp_passdb_backend();
}
/* account policy operations */
if ((checkparms & BIT_ACCPOLICY) && !(checkparms & ~(BIT_ACCPOLICY + BIT_ACCPOLVAL))) {
- uint32 value;
+ uint32_t value;
enum pdb_policy_type field = account_policy_name_to_typenum(account_policy);
if (field == 0) {
const char **names;
home_drive, logon_script,
profile_path, account_control,
user_sid, user_domain,
- badpw_reset, hours_reset);
+ badpw_reset, hours_reset,
+ kickoff_time);
}
}
}