第 5 章 配置基于时间的帐户锁定策略
您可以使用 Account Policy 插件配置不同的基于时间的锁定策略,例如:
5.1. 在最后成功登录后自动禁用帐户一定时间 复制链接链接已复制到粘贴板!
按照以下步骤配置基于时间的锁定策略,该策略会在 dc=example,dc=com 条目下的用户中激活,且不能为超过 21 天登录。
此帐户不活动功能,例如,如果员工留有公司,并且管理员忘记删除帐户,而目录服务器在一定时间后激活帐户。
流程
启用帐户策略插件:
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 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 --state-attr lastLoginTime --alt-state-attr 1.1 --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 --state-attr lastLoginTime --alt-state-attr 1.1 --spec-attr acctPolicySubentry --limit-attr accountInactivityLimitCopy to Clipboard Copied! Toggle word wrap Toggle overflow 这个命令使用以下选项:
-
--always-record-login yes:启用登录时间的日志记录。这需要使用带帐户策略的类服务(CoS)或角色,即使它没有设置acctPolicySubentry属性。 -
--state-attr lastLoginTime:配置帐户策略插件会在用户的lastLoginTime属性中存储最后一次登录时间。 -
--Alt-state-attr 1.1:禁用使用替代属性来检查主属性是否不存在。默认情况下,Directory 服务器使用createTimestamp属性作为替代方案。但是,这会导致如果其帐户没有设置lastLoginTime属性并且createTimestamp比配置的不活跃周期更旧,Directory 服务器会自动记录现有用户。禁用 alternative 属性会导致 Directory 服务器在下次登录时自动将lastLoginTime属性添加到用户条目中。 -
--spec-attr acctPolicySubentry: Configures Directory Server 应用策略到设置了acctPolicySubentry属性的条目。您可以在 CoS 条目中配置此属性。 -
--limit-attr accountInactivityLimit: Configures that theaccountInactivityLimit属性 in inivation policy entry store the inactive time.
-
重启实例:
dsctl instance_name restart
# dsctl instance_name restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow 创建激活策略条目的帐户:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow accountInactivityLimit属性中的值配置在最后一次登录后,目录服务器处于激活的1814400秒(21 天)。创建 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。
验证
将用户的
lastLoginTime属性设置为早于您配置的不活跃时间的值: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" 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 如果目录服务器拒绝访问并返回这个错误,则帐户不活跃工作。