使用者自主更改LDAP密碼的PHP WEB程式

2021-10-10 02:17:33 字數 1334 閱讀 5294

本文供系​​統管理員參考。它將描述如何使用php指令碼更改ldap密碼。為了使用此php指令碼,您只需要更改幾個引數,並在fedora 33上進行了測試。

使用php指令碼更改ldap密碼的步驟

1、確保已正確配置ldap:

2、禁用selinux

sed -i 's/selinux\=enforcing/selinux\=disabled/g' /etc/selinux/config

3、將php-ldap軟體包安裝到apache伺服器中:

# yum install php-ldap -y

4、建立changepassword.php檔案並將其放入您的apache根目錄:

# vi /var/www/html/changepassword.php

修改.php檔案中的$ server和$ dn:

<?php

$message = array();

function changepassword($user,$oldpassword,$newpassword,$newpasswordcnf)

if ($newpassword != $newpasswordcnf )

if (strlen($newpassword) < 4 )

if (!preg_match("/[0-9]/",$newpassword))

if (!preg_match("/[a-za-z]/",$newpassword))

if (!preg_match("/[a-z]/",$newpassword))

if (!preg_match("/[a-z]/",$newpassword))

/* change the password finally */

$entry = array();

$entry["userpassword"] = "" . base64_encode( pack( "h*", sha1( $newpassword ) ) );

if (ldap_modify($con,$user,$entry) === false) else

}?>

<?php

if (isset($_post["submitted"]))

} ?>

5、訪問http://server-ip/changepassword.php,進行密碼更改。

更改MySQL使用者密碼

方法一 適用於管理員或者有全域性許可權的使用者重設其它使用者的密碼 進入命令列模式 mysql u root p mysql use mysql mysql update user set password password new password where user username mysq...

更改MySQL使用者密碼

方法一 適用於管理員或者有全域性許可權的使用者重設其它使用者的密碼 進入命令列模式 mysql u root p mysql use mysql mysql update user set password password new password where user username mysq...

mysql更改使用者密碼

1 mysqladmin mysqladmin u username p password new password 2 手工更新授權表 mysql update user set password password new password where user username mysql fl...