5.3. 在密码过期后自动禁用帐户一定时间
按照以下步骤配置基于时间的锁定策略,该策略在 dc=example,dc=com 条目下的用户中激活,并且不会为超过 28 天更改其密码。
先决条件
-
用户必须在其条目中设置
passwordExpirationTime属性。
流程
启用密码过期功能:
dsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=on
# dsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=ondsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=ondsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=ondsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=ondsconf -D "cn=Directory Manager" ldap://server.example.com config replace passwordExp=onCopy to Clipboard Copied! Toggle word wrap Toggle overflow 启用帐户策略插件:
dsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enable
# dsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enabledsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enabledsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enabledsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enabledsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy enableCopy to Clipboard Copied! Toggle word wrap Toggle overflow 配置插件配置条目:
dsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimit
# dsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitdsconf -D "cn=Directory Manager" ldap://server.example.com plugin account-policy config-entry set "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config" --always-record-login yes --always-record-login-attr lastLoginTime --state-attr non_existent_attribute --alt-state-attr passwordExpirationTime --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitCopy to Clipboard Copied! Toggle word wrap Toggle overflow 这个命令使用以下选项:
-
--always-record-login yes:启用登录时间的日志记录。这需要使用带帐户策略的类服务(CoS)或角色,即使它没有设置acctPolicySubentry属性。 -
--always-record-login-attr lastLoginTime: 配置 Account Policy 插件在用户的lastLoginTime属性中存储最后一次登录的时间。 -
--state-attr non_existent_attribute:设置用于评估帐户策略到不存在的 dummy 属性的主时间属性。 -
--Alt-state-attr 'passwordExpirationTime:配置插件以使用passwordExpirationTime属性作为要检查的备用属性。 -
--spec-attr acctPolicySubentry: Configures Directory Server 应用策略到设置了acctPolicySubentry属性的条目。您可以在 CoS 条目中配置此属性。 -
--limit-attr accountInactivityLimit:配置帐户策略条目中的accountInactivityLimit属性会在帐户上次更改密码后被激活时保存时间。
-
重启实例:
dsctl instance_name restart
# dsctl instance_name restartdsctl instance_name restartdsctl instance_name restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow 创建激活策略条目的帐户:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow accountInactivityLimit属性中的值用来控制,在更改密码后,目录服务器使帐户不活跃2419200秒(28 天)。创建 CoS 模板条目:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此模板条目引用帐户正在激活策略。
创建 CoS 定义条目:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此定义条目引用 CoS 模板条目,并导致
acctPolicySubentry属性出现在每个用户条目中,值设为cn=Account Inactivation Policy,dc=example,dc=com。
验证
将用户的
passwordExpirationTime属性设置为比您配置的不活跃时间超过不活跃时间的值:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 尝试以这个用户身份连接到该目录:
ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"
# ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com"ldapsearch -H ldap://server.example.com -x -D "uid=example,ou=People,dc=example,dc=com" -W -b "dc=example,dc=com" ldap_bind: Constraint violation (19) additional info: Account inactivity limit exceeded. Contact system administrator to reset.Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果目录服务器拒绝访问并返回这个错误,则帐户不活跃工作。