当前位置: 首页>>代码示例>>PHP>>正文


PHP clladp::Ldap_rename_dn方法代码示例

本文整理汇总了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");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:47,代码来源:domains.computer.modifyname.php

示例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}");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:36,代码来源:domains.edit.group.rename.php


注:本文中的clladp::Ldap_rename_dn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。