Esempio n. 1
0
function DelDNSEntry()
{
    $ldap = new clladp();
    if (!$ldap->ldap_delete($_GET["DelDNSEntry"])) {
        echo $ldap->ldap_last_error;
    }
}
function Confirm()
{
    $ldap = new clladp();
    $dn = base64_decode($_GET["dn"]);
    if ($dn == null) {
        echo "DN IS NULL";
        return;
    }
    if (!$ldap->ldap_delete(base64_decode($_GET["dn"]))) {
        echo $ldap->ldap_last_error;
    }
}
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");
    }
}
Esempio n. 4
0
function EditRelayDomain()
{
    $relayIP = $_GET["EditRelayDomainIP"];
    $relayPort = $_GET["EditRelayDomainPort"];
    $domain_name = $_GET["EditRelayDomainName"];
    $MX = $_GET["MX"];
    $ldap = new clladp();
    $ou = $_GET["ou"];
    $autoaliases = $_GET["autoaliases"];
    $trusted_smtp_domain = $_GET["trusted_smtp_domain"];
    $auto = new AutoAliases($ou);
    if ($autoaliases == "yes") {
        $auto->DomainsArray[$domain_name] = $domain_name;
    } else {
        unset($auto->DomainsArray[$domain_name]);
    }
    $auto->Save();
    writelogs("saving relay:{$relayIP}:{$relayPort} trusted_smtp_domain={$trusted_smtp_domain}", __FUNCTION__, __FILE__, __LINE__);
    $dn = "cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd = array();
        $upd['cn'][0] = "transport_map";
        $upd['objectClass'][0] = 'PostFixStructuralClass';
        $upd['objectClass'][1] = 'top';
        $ldap->ldap_add($dn, $upd);
        unset($upd);
    }
    if ($MX == "no") {
        $relayIP = "[{$relayIP}]";
    }
    $dn = "cn={$domain_name},cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}";
    if ($ldap->ExistsDN($dn)) {
        $ldap->ldap_delete($dn);
    }
    writelogs("Create {$dn}", __FUNCTION__, __FILE__);
    $upd = array();
    $upd['cn'][0] = "{$domain_name}";
    $upd['objectClass'][0] = 'transportTable';
    $upd['objectClass'][1] = 'top';
    $upd["transport"][] = "relay:{$relayIP}:{$relayPort}";
    if (!$ldap->ldap_add($dn, $upd)) {
        echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
        return;
    }
    unset($upd);
    $dn = "cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd = array();
        $upd['cn'][0] = "relay_recipient_maps";
        $upd['objectClass'][0] = 'PostFixStructuralClass';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
            return;
        }
        unset($upd);
    }
    $dn = "cn=@{$domain_name},cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    if ($ldap->ExistsDN($dn)) {
        $ldap->ldap_delete($dn);
    }
    if ($trusted_smtp_domain == 1) {
        $upd = array();
        $upd['cn'][0] = "@{$domain_name}";
        $upd['objectClass'][0] = 'PostfixRelayRecipientMaps';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
            return;
        }
    }
    $sock = new sockets();
    $usr = new usersMenus();
    $sock->getFrameWork("cmd.php?postfix-transport-maps=yes");
}
function DeleteOU()
{
    $user = new usersMenus();
    if ($user->AsArticaAdministrator == true) {
        $ldap = new clladp();
        $ldap->ldap_delete("ou={$_GET["DeleteOU"]},dc=organizations,{$ldap->suffix}", true);
    }
}
Esempio n. 6
0
function PostfixDeleteRelayRecipient(){
	$domain=$_GET["PostfixDeleteRelayRecipient"];
	$ldap=new clladp();
	$dn="cn=$domain,cn=relay_recipient_maps ,cn=artica,$ldap->suffix";
	$ldap->ldap_delete($dn,false);	
	$sock=new sockets();
	$sock->getFrameWork("services.php?postfix-single=yes");	
	}
function remotedomain_edit()
{
    $relayIP = $_POST["destination"];
    $relayPort = $_POST["port"];
    $domain_name = $_POST["remotedomain"];
    $MX = $_POST["MX"];
    $ldap = new clladp();
    $ou = $_POST["ou"];
    $trusted_smtp_domain = $_POST["trusted_smtp_domain"];
    if ($MX == 0) {
        $MX = "no";
    } else {
        $MX = "yes";
    }
    writelogs("saving relay:{$relayIP}:{$relayPort} trusted_smtp_domain={$trusted_smtp_domain}", __FUNCTION__, __FILE__, __LINE__);
    $dn = "cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd = array();
        $upd['cn'][0] = "transport_map";
        $upd['objectClass'][0] = 'PostFixStructuralClass';
        $upd['objectClass'][1] = 'top';
        $ldap->ldap_add($dn, $upd);
        unset($upd);
    }
    if ($MX == "no") {
        $relayIP = "[{$relayIP}]";
    }
    $dn = "cn={$domain_name},cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}";
    if ($ldap->ExistsDN($dn)) {
        $ldap->ldap_delete($dn);
    }
    writelogs("Create {$dn}", __FUNCTION__, __FILE__);
    $upd = array();
    $upd['cn'][0] = "{$domain_name}";
    $upd['objectClass'][0] = 'transportTable';
    $upd['objectClass'][1] = 'top';
    $upd["transport"][] = "relay:{$relayIP}:{$relayPort}";
    if (!$ldap->ldap_add($dn, $upd)) {
        echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
        return;
    }
    unset($upd);
    $dn = "cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd = array();
        $upd['cn'][0] = "relay_recipient_maps";
        $upd['objectClass'][0] = 'PostFixStructuralClass';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
            return;
        }
        unset($upd);
    }
    $dn = "cn=@{$domain_name},cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    if ($ldap->ExistsDN($dn)) {
        $ldap->ldap_delete($dn);
    }
    if ($trusted_smtp_domain == 1) {
        $upd = array();
        $upd['cn'][0] = "@{$domain_name}";
        $upd['objectClass'][0] = 'PostfixRelayRecipientMaps';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo "Error\n" . "Line: " . __LINE__ . "\n{$ldap->ldap_last_error}";
            return;
        }
    }
    ChockServices();
}
function DNS_DEL_ENTRY($value)
{
    $hostname = base64_decode($value);
    $EXEC_NICE = EXEC_NICE();
    if (is_file("/usr/bin/nohup")) {
        $nohup = "/usr/bin/nohup ";
    }
    $reload_datas = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-dns >/dev/null 2>&1 &";
    include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
    $ldap = new clladp();
    $upd = array();
    $tbl = explode(".", $hostname);
    $dc = "dc=" . @implode(",dc=", $tbl);
    if ($ldap->ExistsDN("{$dc},ou=dns,{$ldap->suffix}")) {
        if ($ldap->ldap_delete("{$dc},ou=dns,{$ldap->suffix}", true)) {
            send_email_events("Success deleting DNS entry {$hostname}", "DN removed was : {$dc},ou=dns,{$ldap->suffix}", "CLOUD");
            return true;
        }
    } else {
        events("unable to stat {$dc},ou=dns,{$ldap->suffix}", __FUNCTION__, __FILE__, __LINE__);
    }
    $suffix = "ou=dns,{$ldap->suffix}";
    $pattern = "(&(objectclass=*)(associatedDomain={$hostname}))";
    $sr = @ldap_search($ldap->ldap_connection, $suffix, "{$pattern}", array());
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        for ($i = 0; $i < $hash["count"]; $i++) {
            $dn = $hash[$i]["dn"];
            if (strlen($dn) > 0) {
                $dns[] = $dn;
                events("removing  associateddomain={$hostname} in {$dn}", __FUNCTION__, __FILE__, __LINE__);
                $upd["associateddomain"] = $hostname;
                if (!$ldap->Ldap_del_mod($dn, $upd)) {
                    $dns[] = $ldap->ldap_last_error;
                }
            }
        }
        send_email_events("Success executing remove DNS entry {$hostname}", @implode("\n", $dns), "CLOUD");
        return true;
    }
    events("Failed -> notify", __FUNCTION__, __FILE__, __LINE__);
    send_email_events("Failed remove DNS entry {$hostname} does not exists", null, "CLOUD");
    shell_exec($reload_datas);
    return true;
}
Esempio n. 9
0
function users_delete()
{
    $ldap = new clladp();
    $ldap->ldap_delete($_GET["deleteuserdn"], true);
    echo users_table($_GET["ou"], $_GET["domain"]);
}
function DeleteMember()
{
    $usermenu = new usersMenus();
    $tpl = new templates();
    if ($usermenu->AllowAddUsers == false) {
        echo $tpl->_ENGINE_parse_body('{no_privileges}');
        exit;
    }
    $ldap = new clladp();
    $Userdatas = $ldap->UserDatas($_GET["DeleteMember"]);
    $dn = $Userdatas["dn"];
    $ldap->ldap_delete($dn, false);
    if ($ldap->ldap_last_error != null) {
        echo $ldap->ldap_last_error;
    } else {
        echo $tpl->_ENGINE_parse_body('{success}');
        exit;
    }
}
Esempio n. 11
0
function main_access_rules_restore()
{
    $hostname = $_GET["hostname"];
    $squid = new squid($hostname);
    $dn = 'cn=access,' . $squid->dn;
    $ldap = new clladp();
    $ldap->ldap_delete($dn, true);
    $squid->BuildAccessRulesDefault();
}
Esempio n. 12
0
function sasl_delete()
{
    $ldap = new clladp();
    $cn = "cn={$_GET["sasl_delete"]},cn=smtp_sasl_password_maps,cn=artica,{$ldap->suffix}";
    $ldap->ldap_delete($cn, true);
}
Esempio n. 13
0
function DeleteRobot()
{
    $ldap = new clladp();
    $H = $ldap->UserDatas($_GET["DeleteRobot"]);
    $dn = $H["dn"];
    $ldap->ldap_delete($dn, true);
}
Esempio n. 14
0
function trusted_smtp_domain_save()
{
    $ldap = new clladp();
    $domain_name = $_GET["domain"];
    $ou = $_GET["ou"];
    $upd = array();
    $trusted_smtp_domain = $_GET["trusted_smtp_domain"];
    $dn = "cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        $upd['cn'][0] = "relay_recipient_maps";
        $upd['objectClass'][0] = 'PostFixStructuralClass';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo $ldap->ldap_last_error;
            return;
        }
        unset($upd);
    }
    $dn = "cn=@{$domain_name},cn=relay_recipient_maps,ou={$ou},dc=organizations,{$ldap->suffix}";
    $ldap->ldap_delete($dn);
    if ($trusted_smtp_domain == 1) {
        $upd['cn'][0] = "@{$domain_name}";
        $upd['objectClass'][0] = 'PostfixRelayRecipientMaps';
        $upd['objectClass'][1] = 'top';
        if (!$ldap->ldap_add($dn, $upd)) {
            echo $ldap->ldap_last_error;
            return;
        }
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-transport-maps=yes");
}
Esempio n. 15
0
function CONTACT_DELETE()
{
    $employeeNumber = $_GET["delete-contact"];
    $ct = new contacts($_SESSION["uid"], $employeeNumber);
    if ($_SESSION["uid"] != -100) {
        $ldap = new clladp();
        $user = new user($_SESSION["uid"]);
        $dn = "cn={$ct->sn} {$ct->givenName},ou={$user->uid},ou=People,dc={$user->ou},dc=NAB,{$ldap->suffix}";
        if ($dn == $ct->dn) {
            $ldap->ldap_delete($ct->dn, true);
            $sock = new sockets();
            $sock->getfile("OBMContactDelete:{$ct->uidNumber}");
        } else {
            $tpl = new templates();
            echo $tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
        }
    }
}
function smtpd_client_restrictions_save()
{
    $ldap = new clladp();
    if (!$ldap->ExistsDN("cn=restrictions_classes,cn=artica,{$ldap->suffix}")) {
        $upd["objectClass"][] = "top";
        $upd["objectClass"][] = "top";
        $upd["objectClass"][] = "PostFixStructuralClass";
        $upd["cn"][0] = "restrictions_classes";
        if (!$ldap->ldap_add("cn=restrictions_classes,cn=artica,{$ldap->suffix}", $upd)) {
            echo "cn=restrictions_classes,cn=artica,{$ldap->suffix}\n{$ldap->ldap_last_error}";
            return null;
        }
    }
    if ($ldap->ExistsDN("cn=smtpd_client_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}")) {
        $ldap->ldap_delete("cn=smtpd_client_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", false);
        $upd1["objectClass"][] = "top";
        $upd1["objectClass"][] = "PostFixRestrictionStandardClasses";
        $upd1["cn"][0] = "smtpd_client_restrictions";
        if (!$ldap->ldap_add("cn=smtpd_client_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", $upd1)) {
            echo "Modify smtpd_client_restrictions branch\n{$ldap->ldap_last_error}";
            return null;
        }
    }
    unset($upd1);
    if ($ldap->ExistsDN("cn=smtpd_helo_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}")) {
        $ldap->ldap_delete("cn=smtpd_helo_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", false);
    }
    if (!$ldap->ExistsDN("cn=smtpd_helo_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}")) {
        $upd1["objectClass"][] = "top";
        $upd1["objectClass"][] = "PostFixRestrictionStandardClasses";
        $upd1["cn"][0] = "smtpd_helo_restrictions";
        if (!$ldap->ldap_add("cn=smtpd_helo_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", $upd1)) {
            echo "Modify smtpd_helo_restrictions branch\n{$ldap->ldap_last_error}";
            return null;
        }
    }
    $EnablePostfixAntispamPack = $_GET["EnablePostfixAntispamPack"];
    $upd_vals["PostFixRestrictionClassList"][] = "permit_mynetworks=\"\"";
    $upd_vals["PostFixRestrictionClassList"][] = "permit_sasl_authenticated=\"\"";
    $upd_vals["PostFixRestrictionClassList"][] = "check_client_access=\"hash:/etc/postfix/postfix_allowed_connections\"";
    if ($_GET["reject_unknown_client_hostname"] == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_unknown_client_hostname=\"\"";
    }
    if ($_GET["reject_invalid_hostname"] == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_invalid_hostname=\"\"";
    }
    if ($_GET["reject_unknown_reverse_client_hostname"] == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_unknown_reverse_client_hostname=\"\"";
    }
    if ($_GET["reject_unknown_sender_domain"] == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_unknown_sender_domain=\"\"";
    }
    if ($_GET["reject_non_fqdn_sender"] == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_non_fqdn_sender=\"\"";
    }
    if ($EnablePostfixAntispamPack == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "reject_rbl_client=\"zen.spamhaus.org\"";
        $upd_vals["PostFixRestrictionClassList"][] = "reject_rbl_client=\"sbl.spamhaus.org\"";
        $upd_vals["PostFixRestrictionClassList"][] = "reject_rbl_client=\"cbl.abuseat.org\"";
    }
    $upd_vals["PostFixRestrictionClassList"][] = "permit=\"\"";
    $sock = new sockets();
    $sock->SET_INFO('EnablePostfixAntispamPack', $EnablePostfixAntispamPack);
    $sock->SET_INFO('reject_forged_mails', $_GET["reject_forged_mails"]);
    if (!$ldap->Ldap_modify("cn=smtpd_client_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", $upd_vals)) {
        echo "Modify smtpd_client_restrictions branch\n{$ldap->ldap_last_error}";
        return null;
    }
    unset($upd_vals);
    if ($EnablePostfixAntispamPack == 1) {
        $upd_vals["PostFixRestrictionClassList"][] = "permit_mynetworks=\"\"";
        $upd_vals["PostFixRestrictionClassList"][] = "permit_sasl_authenticated=\"\"";
        $upd_vals["PostFixRestrictionClassList"][] = "check_client_access=\"hash:/etc/postfix/postfix_allowed_connections\"";
        $upd_vals["PostFixRestrictionClassList"][] = "reject_non_fqdn_hostname=\"\"";
        $upd_vals["PostFixRestrictionClassList"][] = "reject_invalid_hostname=\"\"";
        $upd_vals["PostFixRestrictionClassList"][] = "permit=\"\"";
        if (!$ldap->Ldap_modify("cn=smtpd_helo_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}", $upd_vals)) {
            echo "Modify datas in smtpd_helo_restrictions branch\n{$ldap->ldap_last_error}";
            return null;
        }
    }
    $main = new main_cf();
    $main->save_conf_to_server(1);
    $sock = new sockets();
    $tpl = new templates();
    $sock->getFrameWork("cmd.php?reconfigure-postfix=yes");
}
Esempio n. 17
0
function catchall_save()
{
    $ou = $_GET["ou"];
    $domain = $_GET["domain"];
    $ldap = new clladp();
    if (trim($_GET["catch-all-addr"]) == null) {
        $dn = "cn=@{$domain},cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
        if ($ldap->ExistsDN($dn)) {
            $ldap->ldap_delete($dn);
            return null;
        }
    }
    $email = $_GET["catch-all-addr"] . "@{$domain}";
    $tpl = new templates();
    $uid = $ldap->uid_from_email($email);
    if ($uid == null) {
        echo $tpl->_ENGINE_parse_body('{error_no_user_exists}');
        return null;
    }
    $ct = new user($uid);
    if ($ct->ou != $ou) {
        echo $tpl->_ENGINE_parse_body('{error_no_user_exists}');
        return null;
    }
    $dn = "cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "catch-all";
            $upd['objectClass'][0] = 'PostFixStructuralClass';
            $upd['objectClass'][1] = 'top';
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $dn = "cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "{$ou}";
            $upd['objectClass'][0] = 'PostFixStructuralClass';
            $upd['objectClass'][1] = 'top';
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $dn = "cn=@{$domain},cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
    if (!$ldap->ExistsDN($dn)) {
        if (!$ldap->ExistsDN($dn)) {
            $upd['cn'][0] = "@{$domain}";
            $upd['objectClass'][0] = 'AdditionalPostfixMaps';
            $upd['objectClass'][1] = 'top';
            $upd['CatchAllPostfixAddr'][0] = "{$email}";
            if (!$ldap->ldap_add($dn, $upd)) {
                echo $ldap->ldap_last_error;
                return null;
            }
            unset($upd);
        }
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-hash-aliases=yes");
}
Esempio n. 18
0
    echo "No ldapadd !!\n";
    return;
}
if ($newou == null) {
    echo "No destination\n";
    return;
}
if ($ou == null) {
    echo "No org source\n";
    return;
}
@mkdir("/usr/share/artica-postfix/ressources/ldap-back/{$ou}", null, true);
$tmpfile = "/usr/share/artica-postfix/ressources/ldap-back/{$ou}/{$ou}.ldif";
$dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
ExportDN($ou, $newou, $dn);
$ldap->ldap_delete($dn, true);
$dn = "cn={$ou},cn=catch-all,cn=artica,{$ldap->suffix}";
if ($ldap->ExistsDN($dn)) {
    ExportDN($ou, $newou, $dn);
    $ldap->ldap_delete($dn, true);
}
$dn = "cn={$ou},cn=PostfixRobots,cn=artica,{$ldap->suffix}";
if ($ldap->ExistsDN($dn)) {
    ExportDN($ou, $newou, $dn);
    $ldap->ldap_delete($dn, true);
}
$dn = "dc={$ou},dc=NAB,{$ldap->suffix}";
if ($ldap->ExistsDN($dn)) {
    ExportDN($ou, $newou, $dn);
    $ldap->ldap_delete($dn, true);
}
Esempio n. 19
0
function remove($servername)
{
    $apache = new vhosts();
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    $confs = $apache->SearchHosts($servername);
    events(__FUNCTION__ . ":: Check {$servername}");
    events(__FUNCTION__ . ":: remove files and directories");
    if (is_dir("/usr/share/artica-groupware/domains/{$servername}")) {
        shell_exec("/bin/rm -rf /usr/share/artica-groupware/domains/{$servername}");
    }
    $server_database = str_replace(" ", "_", $servername);
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace("-", "_", $server_database);
    $q = new mysql();
    if ($q->DATABASE_EXISTS($server_database)) {
        $q->DELETE_DATABASE($server_database);
    }
    $flaseuser["root"] = true;
    $flaseuser["admin"] = true;
    $flaseuser["manager"] = true;
    $sql = "DELETE FROM `mysql`.`db` WHERE `db`.`Db` = '{$server_database}'";
    $q->QUERY_SQL($sql, "mysql");
    events(__FUNCTION__ . ":: removing ldap branch {$confs["dn"]}");
    $ldap = new clladp();
    if ($ldap->ExistsDN($confs["dn"])) {
        $ldap->ldap_delete($confs["dn"]);
    }
    events(__FUNCTION__ . ":: restarting HTTP service...");
    shell_exec("/etc/init.d/artica-postfix restart apache-groupware &");
}
function DeleteGenericPasswordMaps()
{
    $email = base64_decode($_GET["DeleteGenericPasswordMaps"]);
    writelogs("Delete {$email}", __FUNCTION__, __FILE__, __LINE__);
    $ligne = unserialize(base64_decode($_GET["mArray"]));
    if (!is_array($ligne)) {
        echo "mArray !== Not an array()\n";
        return;
    }
    $type = $ligne["type"];
    $passwordt = $ligne["PASSWORD"];
    $type_value = $ligne["value"];
    writelogs("Delete {$type}={$type_value}", __FUNCTION__, __FILE__, __LINE__);
    if ($type == "uid") {
        include_once dirname(__FILE__) . "/ressources/class.user.inc";
        $u = new user($type_value);
        $u->del_transport();
        return;
    }
    if ($type == "dn") {
        $ldap = new clladp();
        if (!$ldap->ldap_delete($type_value)) {
            echo basename(__FILE__) . "\nLine:\n" . __LINE__ . "\nError:{$type_value}\n{$ldap->ldap_last_error}";
            return;
        }
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-relayhost=yes");
    $sock->getFrameWork("cmd.php?postfix-hash-senderdependent=yes");
}
Esempio n. 21
0
function check_client_access_del()
{
    $ldap = new clladp();
    $tpl = new templates();
    $dn = "cn={$_GET["check_client_access_del"]},cn=check_client_access,cn=smtpd_client_restrictions,cn=restrictions_classes,cn=artica,{$ldap->suffix}";
    if (!$ldap->ldap_delete($dn, true)) {
        echo $ldap->ldap_last_error;
    } else {
        echo $tpl->_ENGINE_parse_body("{success}:{delete} {rule}:{$_GET["check_client_access_del"]}");
    }
}
Esempio n. 22
0
function mount_delete()
{
    $ldap = new clladp();
    $dn = "cn={$_GET["AutoMountDelete"]},ou=auto.automounts,ou=mounts,{$ldap->suffix}";
    if (!$ldap->ldap_delete($dn)) {
        echo $ldap->ldap_last_error;
    }
}
Esempio n. 23
0
function TreeDeleteOrganisation()
{
    $usr = new usersMenus();
    $tpl = new templates();
    $ou = $_GET["TreeDeleteOrganisation"];
    if ($usr->AsArticaAdministrator == false) {
        echo $tpl->_ENGINE_parse_body('{no_privileges}');
        exit;
    }
    $ldap = new clladp();
    $ldap->ldap_delete("ou={$ou},dc=organizations,{$ldap->suffix}", true);
    if ($ldap->ldap_last_error != null) {
        echo $ldap->ldap_last_error;
        exit;
    }
    echo $tpl->_ENGINE_parse_body("{$ou} {deleted}");
}
Esempio n. 24
0
function popup_users_list()
{
    $computer = new computers($_GET["uid"]);
    $tpl = new templates();
    if ($computer->ComputerMacAddress == null) {
        $computer->ComputerMacAddress = $_GET["uid"];
    }
    if (isset($_GET["deletedn"])) {
        if (IsRightOnlyAdmin()) {
            $basedn = base64_decode($_GET["deletedn"]);
            $ldap = new clladp();
            $ldap->ldap_delete($basedn);
        }
    }
    echo $tpl->_ENGINE_parse_body("<H3 style='margin-bottom:8px'>{ComputerMacAddress}:{$computer->ComputerMacAddress}</H3>");
    $dn = $userid->dn;
    $ldap = new clladp();
    $pattern = "(&(objectClass=ComputerAfectation)(cn={$computer->ComputerMacAddress}))";
    $attr = array();
    $sr = @ldap_search($ldap->ldap_connection, $ldap->suffix, $pattern, $attr);
    if (!$sr) {
        return null;
    }
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    if ($hash["count"] == 0) {
        return;
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $basedn = base64_encode($hash[$i]["dn"]);
        $js = "javascript:DeleteComputerDN('{$basedn}');";
        if (preg_match("#cn=hosts,cn=(.+?),ou=users,ou=(.+?),dc=organizations#", $hash[$i]["dn"], $re)) {
            $tbl[] = "<div style='float:left'>" . Paragraphe("user-server-64-delete.png", $re[1], "{organization}: {$re[2]}", $js) . "</div>";
        }
    }
    if (!is_array($tbl)) {
        return null;
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body(implode("\n", $tbl));
}
Esempio n. 25
0
function USER_DELETE()
{
    //remove user
    $ldap = new clladp();
    $hash = $ldap->UserDatas($_GET["DeleteThisUser"]);
    if ($hash["dn"] != null) {
        if ($hash["dn"] != $ldap->suffix) {
            if ($ldap->ExistsDN($hash["dn"])) {
                writelogs("delete dn {$hash["dn"]}", __FUNCTION__, __FILE__, __LINE__);
                $ldap->ldap_delete($hash["dn"], false);
            }
        }
    }
    $hash = $ldap->UserGetGroups($_GET["DeleteThisUser"]);
    if (is_array($hash)) {
        while (list($num, $ligne) = each($hash)) {
            if (!$ldap->UserDeleteToGroup($_GET["DeleteThisUser"], $ligne)) {
                echo $ldap->ldap_last_error;
                exit;
            }
        }
    }
}
Esempio n. 26
0
function mailman_change_email_robot()
{
    $id = $_GET["id"];
    $ldap = new clladp();
    $email_new = $_GET["email_new"];
    $robot_type = $_GET["robot_type"];
    $dn1 = "cn={$_GET["mailman_change_email_robot"]},cn={$id},cn=mailman,cn=artica,{$ldap->suffix}";
    $ldap->ldap_delete($dn1, true);
    $upd["objectclass"][] = 'top';
    $upd["objectclass"][] = 'ArticaMailManRobots';
    $upd["cn"][] = "{$email_new}";
    $upd["MailManDistriList"][] = $id;
    $upd["MailManRobotType"][] = $robot_type;
    $ldap->ldap_add("cn={$email_new},cn={$id},cn=mailman,cn=artica,{$ldap->suffix}", $upd);
}
Esempio n. 27
0
function DeleteGroup()
{
    if (isset($_GET["DeleteGroup"])) {
        $gpid = $_GET["DeleteGroup"];
    }
    if (isset($_GET["delgroup"])) {
        $gpid = $_GET["delgroup"];
    }
    $ou = $_GET["ou"];
    $ldap = new clladp();
    $tpl = new templates();
    $classGroup = new groups($gpid);
    $hashgroup = $ldap->GroupDatas($gpid);
    $default_dn_nogroup = "cn=nogroup,ou=groups,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ExistsDN($default_dn_nogroup)) {
        $ldap->AddGroup("nogroup", $ou);
    }
    $nogroup_id = $ldap->GroupIDFromName($ou, "nogroup");
    if (is_array($hashgroup["members"])) {
        while (list($num, $val) = each($hashgroup["members"])) {
            $ldap->AddUserToGroup($nogroup_id, $num);
        }
    }
    $users = new usersMenus();
    if ($users->KAV_MILTER_INSTALLED) {
        $sock = new sockets();
        $sock->getfile("KavMilterDeleteRule:{$classGroup->groupName}.{$classGroup->ou}");
    }
    $kas_dn = "cn={$gpid},cn=kaspersky Antispam 3 rules,cn=artica,{$ldap->suffix}";
    if ($ldap->ExistsDN($kas_dn)) {
        $ldap->ldap_delete($kas_dn, false);
    }
    $ldap->ldap_delete($hashgroup["dn"], false);
    if ($ldap->ldap_last_error != null) {
        echo $ldap->ldap_last_error;
    } else {
        echo $tpl->_ENGINE_parse_body('{success}');
    }
}
Esempio n. 28
0
function wbl_robots_delete()
{
    $email = $_GET["DeleteRobot"];
    if (!isset($_GET["ou"])) {
        die('No organization');
    }
    $ou = $_GET["ou"];
    $users = new usersMenus();
    if ($users->AllowEditOuSecurity == false) {
        $tpl = new templates();
        $error = "\n{ERROR_NO_PRIVS}\n";
        echo $tpl->_ENGINE_parse_body($error);
        die;
    }
    $ldap = new clladp();
    $dn = "cn={$email},cn=whitelists,cn={$ou},cn=PostfixRobots,cn=artica,{$ldap->suffix}";
    if (!$ldap->ldap_delete($dn)) {
        echo $ldap->ldap_last_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?postfix-hash-tables=yes");
}
Esempio n. 29
0
function DeleteGlobalBlack()
{
    $num = $_GET["DeleteGlobalBlack"];
    $ou = $_GET["ou"];
    $ldap = new clladp();
    $tpl = new templates();
    $dn = "cn={$domain},cn=blackListedDomains,ou={$ou},dc=organizations,{$ldap->suffix}";
    if (!$ldap->ldap_delete($dn, true)) {
        echo $tpl->_ENGINE_parse_body("{failed}\n" . $ldap->ldap_last_error);
    } else {
        echo $tpl->_ENGINE_parse_body('{success}');
    }
}
Esempio n. 30
0
function TLSDeleteSMTPServer()
{
    $ldap = new clladp();
    $base_dn = "cn={$_GET["TLSDeleteSMTPServer"]},cn=smtp_tls_policy_maps,cn=artica,{$ldap->suffix}";
    $ldap->ldap_delete($base_dn, true);
}