收到消息Your password will be expired with in 7 days
后,我将default
个人资料的密码过期天数更改为UNLIMITED
。但是某些用户的帐户状态仍然保留在EXPIRE(GRACE)
中。
如何在不重置密码的情况下将Oracle用户帐户状态从EXPIRE(GRACE)
更改为OPEN
?
答案 0 :(得分:24)
不,您无法在不重置密码的情况下将帐户状态从EXPIRE(GRACE)更改为OPEN。
如果使用PASSWORD导致数据库用户密码过期 EXPIRE,然后用户(或DBA)必须更改密码 尝试在到期后登录数据库。
但是,您可以通过将用户的密码哈希重置为现有值来将状态更改为OPEN。不幸的是,将密码哈希设置为自身具有以下复杂性,并且几乎所有其他解决方案都至少错过了其中一个问题:
DEFAULT
,则指向DEFAULT
配置文件的值。我们可能需要递归检查配置文件。以下,可笑的大型PL / SQL块应该处理所有这些情况。无论Oracle版本或配置文件设置如何,它都应使用相同的密码哈希将任何帐户重置为OPEN。并且配置文件将更改回原始限制。
--Purpose: Change a user from EXPIRED to OPEN by setting a user's password to the same value.
--This PL/SQL block requires elevated privileges and should be run as SYS.
--This task is difficult because we need to temporarily change profiles to avoid
-- errors like "ORA-28007: the password cannot be reused".
--
--How to use: Run as SYS in SQL*Plus and enter the username when prompted.
-- If using another IDE, manually replace the variable two lines below.
declare
v_username varchar2(128) := trim(upper('&USERNAME'));
--Do not change anything below this line.
v_profile varchar2(128);
v_old_password_reuse_time varchar2(128);
v_uses_default_for_time varchar2(3);
v_old_password_reuse_max varchar2(128);
v_uses_default_for_max varchar2(3);
v_alter_user_sql varchar2(4000);
begin
--Get user's profile information.
--(This is tricky because there could be an indirection to the DEFAULT profile.
select
profile,
case when user_password_reuse_time = 'DEFAULT' then default_password_reuse_time else user_password_reuse_time end password_reuse_time,
case when user_password_reuse_time = 'DEFAULT' then 'Yes' else 'No' end uses_default_for_time,
case when user_password_reuse_max = 'DEFAULT' then default_password_reuse_max else user_password_reuse_max end password_reuse_max,
case when user_password_reuse_max = 'DEFAULT' then 'Yes' else 'No' end uses_default_for_max
into v_profile, v_old_password_reuse_time, v_uses_default_for_time, v_old_password_reuse_max, v_uses_default_for_max
from
(
--User's profile information.
select
dba_profiles.profile,
max(case when resource_name = 'PASSWORD_REUSE_TIME' then limit else null end) user_password_reuse_time,
max(case when resource_name = 'PASSWORD_REUSE_MAX' then limit else null end) user_password_reuse_max
from dba_profiles
join dba_users
on dba_profiles.profile = dba_users.profile
where username = v_username
group by dba_profiles.profile
) users_profile
cross join
(
--Default profile information.
select
max(case when resource_name = 'PASSWORD_REUSE_TIME' then limit else null end) default_password_reuse_time,
max(case when resource_name = 'PASSWORD_REUSE_MAX' then limit else null end) default_password_reuse_max
from dba_profiles
where profile = 'DEFAULT'
) default_profile;
--Get user's password information.
select
'alter user '||name||' identified by values '''||
spare4 || case when password is not null then ';' else null end || password ||
''''
into v_alter_user_sql
from sys.user$
where name = v_username;
--Change profile limits, if necessary.
if v_old_password_reuse_time <> 'UNLIMITED' then
execute immediate 'alter profile '||v_profile||' limit password_reuse_time unlimited';
end if;
if v_old_password_reuse_max <> 'UNLIMITED' then
execute immediate 'alter profile '||v_profile||' limit password_reuse_max unlimited';
end if;
--Change the user's password.
execute immediate v_alter_user_sql;
--Change the profile limits back, if necessary.
if v_old_password_reuse_time <> 'UNLIMITED' then
if v_uses_default_for_time = 'Yes' then
execute immediate 'alter profile '||v_profile||' limit password_reuse_time default';
else
execute immediate 'alter profile '||v_profile||' limit password_reuse_time '||v_old_password_reuse_time;
end if;
end if;
if v_old_password_reuse_max <> 'UNLIMITED' then
if v_uses_default_for_max = 'Yes' then
execute immediate 'alter profile '||v_profile||' limit password_reuse_max default';
else
execute immediate 'alter profile '||v_profile||' limit password_reuse_max '||v_old_password_reuse_max;
end if;
end if;
end;
/
答案 1 :(得分:20)
jonearles的答案汇编http://kishantha.blogspot.com/2010/03/oracle-enterprise-manager-console.html和http://blog.flimatech.com/2011/07/17/changing-oracle-password-in-11g-using-alter-user-identified-by-values/(Oracle 11g):
要在将来停止这种情况,请执行以下操作。
ALTER PROFILE DEFAULT LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED PASSWORD_LIFE_TIME UNLIMITED;
要重置用户状态,请运行查询:
select
'alter user ' || su.name || ' identified by values'
|| ' ''' || spare4 || ';' || su.password || ''';'
from sys.user$ su
join dba_users du on ACCOUNT_STATUS like 'EXPIRED%' and su.name = du.username;
并执行部分或全部结果集。
答案 2 :(得分:8)
set long 9999999
set lin 400
select DBMS_METADATA.GET_DDL('USER','YOUR_USER_NAME') from dual;
这将输出如下内容:
SQL> select DBMS_METADATA.GET_DDL('USER','WILIAM') from dual;
DBMS_METADATA.GET_DDL('USER','WILIAM')
--------------------------------------------------------------------------------
CREATE USER "WILIAM" IDENTIFIED BY VALUES 'S:6680C1468F5F3B36B726CE7620F
FD9657F0E0E49AE56AAACE847BA368CEB;120F24A4C2554B4F'
DEFAULT TABLESPACE "USER"
TEMPORARY TABLESPACE "TEMP"
PASSWORD EXPIRE
SQL>
只需使用alter user的第一部分:
ALTER USER "WILIAM" IDENTIFIED BY VALUES 'S:6680C1468F5F3B36B726CE7620F
FD9657F0E0E49AE56AAACE847BA368CEB;120F24A4C2554B4F';
这将使帐户重新处于OPEN状态而不更改密码(只要您从DBMS_METADATA.GET_DDL的输出中正确剪切和粘贴哈希值),您甚至不需要知道密码是什么
答案 3 :(得分:4)
如果您知道该用户的密码,或者您想猜它,请执行以下操作:
connect user/password
如果此命令成功连接,您将看到消息“已连接”,否则您将看到错误消息。如果您是成功的日志记录,那意味着您知道密码。 在这种情况下,只需:
alter user NAME_OF_THE_USER identified by OLD_PASSWORD;
这会将密码重置为与之前相同的密码,并重置该用户的account_status。
答案 4 :(得分:0)
--可以检查系统类型帐户,例如 SYS
SQL> select username, account_status from dba_users where username='BOB';
SQL> select username, account_status from dba_users where username like 'BOB%';
SQL> select username, account_status from dba_users where like '%BOB%';
SQL> ALTER user [username] account UNLOCK;
--解锁它被锁定的帐户
SQL> Alter user [username] IDENTIFIED BY "password";
-- 修改用户密码
答案 5 :(得分:-1)
第1步需要使用以下查询查找用户详细信息
SQL> select username, account_status from dba_users where username='BOB';
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
BOB EXPIRED
第2步,使用以下查询获取用户密码。
SQL>SELECT 'ALTER USER '|| name ||' IDENTIFIED BY VALUES '''|| spare4 ||';'|| password ||''';' FROM sys.user$ WHERE name='BOB';
ALTER USER BOB IDENTIFIED BY VALUES 'S:9BDD17811E21EFEDFB1403AAB1DD86AB481E;T:602E36430C0D8DF7E1E453;2F9933095143F432';
步骤-3在Alter查询上方运行
SQL> ALTER USER BOB IDENTIFIED BY VALUES 'S:9BDD17811E21EFEDFB1403AAB1DD86AB481E;T:602E36430C0D8DF7E1E453;2F9933095143F432';
User altered.
第4步:检查用户帐户状态
SQL> select username, account_status from dba_users where username='BOB';
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
BOB OPEN