第 17 章 配置基于时间的帐户锁定策略
您可以使用帐户策略插件配置不同的基于时间的锁定策略,例如:
17.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: 启用登录时间记录。这需要使用 Class of Service (CoS)或具有帐户策略的角色,即使它没有设置acctPolicySubentry属性。 -
--state-attr lastLoginTime:配置帐户策略插件将最后登录时间存储在用户的lastLoginTime属性中。 -
--Alt-state-attr 1.1:禁止使用 alternative 属性检查主属性是否不存在。默认情况下,Directory 服务器使用createTimestamp属性作为替代方案。但是,如果 Directory 服务器没有设置lastLoginTime属性,并且createTimestamp比配置的不活跃周期旧,则 Directory 服务器会自动注销现有的用户。禁用 alternative 属性会导致 Directory 服务器在下次登录时自动将lastLoginTime属性添加到用户条目。 -
--spec-attr acctPolicySubentry: Configures Directory Server 将策略应用到设置了acctPolicySubentry属性的条目。您可以在 CoS 条目中配置此属性。 -
--limit-attr accountInactivityLimit: 配置 account inactivation 策略条目中的accountInactivityLimit属性存储不活跃的时间。
-
重启实例:
dsctl instance_name restart
# dsctl instance_name restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow 创建 account inactivation 策略条目:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow accountInactivityLimit属性中的值在最后一次登录后将 Directory 服务器配置为激活帐户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" ldap_bind: Constraint violation (19) additional info: Account inactivity limit exceeded. Contact system administrator to reset.
# 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 如果 Directory Server 拒绝访问并返回这个错误,则帐户不活动。