Ejemplo n.º 1
0
static NTSTATUS password_change(const char *remote_mach, char *username, 
				char *old_passwd, char *new_pw,
				int local_flags)
{
	NTSTATUS ret;
	pstring err_str;
	pstring msg_str;

	if (remote_mach != NULL) {
		if (local_flags & (LOCAL_ADD_USER|LOCAL_DELETE_USER|LOCAL_DISABLE_USER|LOCAL_ENABLE_USER|
							LOCAL_TRUST_ACCOUNT|LOCAL_SET_NO_PASSWORD)) {
			/* these things can't be done remotely yet */
			return NT_STATUS_UNSUCCESSFUL;
		}
		ret = remote_password_change(remote_mach, username, 
					     old_passwd, new_pw, err_str, sizeof(err_str));
		if(*err_str)
			fprintf(stderr, "%s", err_str);
		return ret;
	}
	
	ret = local_password_change(username, local_flags, new_pw, 
				     err_str, sizeof(err_str), msg_str, sizeof(msg_str));

	if(*msg_str)
		printf("%s", msg_str);
	if(*err_str)
		fprintf(stderr, "%s", err_str);

	return ret;
}
Ejemplo n.º 2
0
static NTSTATUS password_change(const char *remote_mach, char *username, 
				char *old_passwd, char *new_pw,
				int local_flags)
{
	NTSTATUS ret;
	char *err_str = NULL;
	char *msg_str = NULL;

	if (remote_mach != NULL) {
		if (local_flags & (LOCAL_ADD_USER|LOCAL_DELETE_USER|
				   LOCAL_DISABLE_USER|LOCAL_ENABLE_USER|
				   LOCAL_TRUST_ACCOUNT|LOCAL_SET_NO_PASSWORD)) {
			/* these things can't be done remotely yet */
			fprintf(stderr, "Invalid remote operation!\n");
			return NT_STATUS_UNSUCCESSFUL;
		}
		ret = remote_password_change(remote_mach, username,
					     old_passwd, new_pw, &err_str);
	} else {
		ret = local_password_change(username, local_flags, new_pw,
					    &err_str, &msg_str);
	}

	if (msg_str) {
		printf("%s", msg_str);
	}
	if (err_str) {
		fprintf(stderr, "%s", err_str);
	}
	if (!NT_STATUS_IS_OK(ret) && !err_str) {
		fprintf(stderr, "Failed to change password!\n");
	}

	SAFE_FREE(msg_str);
	SAFE_FREE(err_str);
	return ret;
}