本文整理汇总了PHP中clladp::Ldap_rename_dn方法的典型用法代码示例。如果您正苦于以下问题:PHP clladp::Ldap_rename_dn方法的具体用法?PHP clladp::Ldap_rename_dn怎么用?PHP clladp::Ldap_rename_dn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clladp
的用法示例。
在下文中一共展示了clladp::Ldap_rename_dn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changecomputername
function changecomputername()
{
if (substr($_POST["userid"], strlen($_POST["userid"]) - 1, 1) != "\$") {
$_POST["userid"] = $_POST["userid"] . "\$";
}
$comp = new computers($_POST["userid"]);
$MAC = $comp->ComputerMacAddress;
$_POST["NewHostname"] = trim(strtolower($_POST["NewHostname"]));
$_POST["NewHostname"] = str_replace('$', '', $_POST["NewHostname"]);
$actualdn = $comp->dn;
$newrdn = "cn={$_POST["NewHostname"]}\$";
$ldap = new clladp();
if (!preg_match("#^cn=(.+?),[a-zA-Z\\s]+#", $actualdn, $re)) {
echo "Unable to preg_match {$actualdn}\n";
return;
}
$newDN = str_replace($re[1], $_POST["NewHostname"] . '$', $actualdn);
if ($newDN == null) {
echo "Unable to preg_match {$actualdn} -> {$re[1]}\n";
return;
}
if ($ldap->ExistsDN("{$newrdn},ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}")) {
$ldap->ldap_delete("{$newrdn},ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}");
}
$newParent = "ou=Computer,dc=samba,dc=organizations,{$ldap->suffix}";
if (!$ldap->Ldap_rename_dn($newrdn, $actualdn, $newParent)) {
echo "Rename failed {$ldap->ldap_last_error}\nFunction:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLine" . __LINE__ . "\n\nActual DN:{$actualdn}\nExpected DN:{$newrdn}";
return;
}
$upd["uid"][0] = $_POST["NewHostname"] . '$';
if (!$ldap->Ldap_modify($newDN, $upd)) {
echo "Update UID {$upd["uid"][0]} failed:\n{$ldap->ldap_last_error}\nFunction:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLine" . __LINE__ . "\nExpected DN:{$newDN}\nExpected value:{$_POST["NewHostname"]}";
return;
}
$ocs = new ocs($MAC);
$ocs->ComputerName = $_POST["NewHostname"];
$ocs->ComputerIP = $comp->ComputerIP;
$ocs->EditComputer();
if (IsPhysicalAddress($comp->ComputerMacAddress)) {
include_once dirname(__FILE__) . "/ressources/class.mysql.inc";
$uid = $comp->ComputerIDFromMAC($comp->ComputerMacAddress);
$comp = new computers($uid);
$sql = "UPDATE dhcpd_fixed SET `hostname`='{$comp->ComputerRealName}' WHERE `mac`='{$comp->ComputerMacAddress}'";
$q = new mysql();
$q->QUERY_SQL($sql, "artica_backup");
}
}
示例2: rename_group
function rename_group()
{
$tpl = new templates();
if ($_SESSION["uid"] != -100) {
if ($_GET["ou"] != $_SESSION["ou"]) {
}
echo $tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}");
die;
}
$gp = new groups($_GET["group-id"]);
if ($_SESSION["uid"] != -100) {
if ($gp->ou != $_SESSION["ou"]) {
echo $tpl->_ENGINE_parse_body("{ERROR_NO_PRIVS}");
die;
}
}
$ldap = new clladp();
$newname = $_GET["new-name"];
if (trim($newname) == null) {
return null;
}
$actualdn = $gp->dn;
if (preg_match('#cn=(.+?),(.+)#', $actualdn, $re)) {
$branch = $re[2];
}
$newdn = "cn={$newname}";
$newdn2 = "{$newdn},{$branch}";
$ldap = new clladp();
if ($ldap->ExistsDN($newdn2)) {
return null;
}
writelogs("Rename {$actualdn} to {$newdn}", __CLASS__ . '/' . __FUNCTION__, __FILE__);
if (!$ldap->Ldap_rename_dn($newdn, $actualdn, $branch)) {
echo $tpl->_ENGINE_parse_body("{GROUP_RENAME} {failed}\n {$ldap->ldap_last_error}");
}
}