我已经设置了一个FreeIPA服务器。当第一次创建用户时,我面临一个密码过期的问题。因此,新用户在第一次登录时应该始终设置密码,这是在这里中定义的。但我不想要这个特征。
我使用这个图书馆在FreeIPA中创建或添加用户。
所以,我就像这样和FreeIPA联系-
private function getIPA()
{
$host = env('FREEIPA_HOST', 'cloud-host-ipa.com');
$certificate = database_path(env('FREEIPA_CERTIFICATE', 'ca.crt'));
try {
return new \FreeIPA\APIAccess\Main($host, $certificate);
} catch (Exception $e) {
throw new \ErrorException("Error {$e->getCode()}: {$e->getMessage()}");
return false;
}
}
private function getIPAConnection() //Ged authinticated admin IPA connection
{
$ipa = $this->getIPA();
try {
$auth = $ipa->connection()->authenticate(env('FREEIPA_ADMIN_NAME', 'oc-ipa-connector'), env('FREEIPA_ADMIN_PASS', 'ADMIN_PASS'));
if ($auth) {
return $ipa;
} else {
$auth_info = $ipa->connection()->getAuthenticationInfo();
$auth_info = implode(' ', $auth_info);
throw new \ErrorException("\nLogin Failed : {$auth_info}");
//return false;
}
} catch (Exception $e) {
throw new \ErrorException("\nError {$e->getCode()}: {$e->getMessage()}");
//return false;
}
}
然后添加一个这样的用户-
$ipa = $this->getIPAConnection();
try {
$new_user_data = array(
'givenname' => $givenname,
'sn' => $sn,
'uid' => $uid,
//'userpassword' => $_POST["userpassword"],
'mail' => $mail,
'mobile' => $phone
);
$add_user = $ipa->user()->add($new_user_data);
if ($add_user) {
return true;
}
} catch (Exception $e) {
throw new \ErrorException("Error {$e->getCode()}: {$e->getMessage()}");
return false;
}
此代码工作良好,并添加了用户。
然后我用这个密码设置密码-
$ipa = $this->getIPAConnection();
try {
$user_info = $ipa->user()->get($uid);
if($user_info != false)
{
try {
$new_user_data = array(
'userpassword' => $password,
);
$mod_user = $ipa->user()->modify($uid, $new_user_data);
if ($mod_user) {
return true;
}
else
{
return false;
}
} catch (Exception $e) {
throw new \ErrorException("Error {$e->getCode()}: {$e->getMessage()}");
}
}
} catch (Exception $e) {
throw new \ErrorException("Error {$e->getCode()}: {$e->getMessage()}");
}
密码也设置得很完美。但是set密码在设置之后就会自动过期。
我希望我的用户至少有一个星期的密码。因此,我想禁用这功能。有什么实用的方法吗?
重新-
我在FreeIPA中创建了FreeIPA,为我们提供了一个解决方案,但问题已经结束,并标记为- closed : wontfix。所以,我想知道是否有解决办法?
发布于 2020-02-01 23:42:00
答案是在链接https://www.redhat.com/archives/freeipa-users/2012-June/msg00360.html中提供的。
有一个关于密码的全局策略,您可以从下面的命令中看到:
[server]$ ipa pwpolicy-show Group: global_policy Max lifetime (days): 90 Min lifetime (hours): 1 History size: 0 Character classes: 0 Min length: 8 Max failures: 6 Failure reset interval: 60 Lockout duration: 600
通过运行以下命令,可以为要向其添加用户的组创建新的策略覆盖:
[server]$ ipa pwpolicy-add sysadmin --minlife=0 Priority: 50 Group: sysadmin Min lifetime (hours): 0 Priority: 50
现在,此策略将重写全局密码策略,并仅为组创建策略。
如果要修改全局策略,可以使用命令:[server]$ ipa pwpolicy-mod global_policy --minlife=0 Group: global_policy Max lifetime (days): 90 Min lifetime (hours): 0 History size: 0 Character classes: 0 Min length: 8 Max failures: 6 Failure reset interval: 60 Lockout duration: 600
进行同样的操作。
注意到Min生存期(小时)更改为0,这会导致密码永不过期。
创建用户后,需要从服务器中的脚本运行此代码:
echo -e $PASSWORD\n$PASSWORD\n$PASSWORD | kinit $username kdestroy
请注意,您需要将PASSWORD
和username
作为参数发送到脚本,并远程执行此脚本。
https://stackoverflow.com/questions/59374179
复制相似问题