function moveuser()
{
    $u = new user($_POST["userid"]);
    $dn = $u->dn;
    $gplist = $u->Groups_list();
    if (preg_match("#^(.+?),#", $dn, $re)) {
        $newRdn = $re[1];
    } else {
        $newRdn = "cn={$_POST["userid"]}";
    }
    $ldap = new clladp();
    $newParent = "ou=users,ou={$_POST["nextou"]},dc=organizations,{$ldap->suffix}";
    if (!ldap_rename($ldap->ldap_connection, $dn, $newRdn, $newParent, true)) {
        echo 'Error number ' . ldap_errno($ldap->ldap_connection) . "\nAction:LDAP Ldap_rename\ndn:{$dn} -> {$newRdn},{$newParent}\n" . ldap_err2str(ldap_errno($ldap->ldap_connection));
        return;
    }
    while (list($gid, $name) = each($gplist)) {
        $gp = new groups($gid);
        $gp->DeleteUserFromThisGroup($_POST["userid"]);
    }
}
Ejemplo n.º 2
0
function Confirm()
{
    $group = new groups($_GET["gpid"]);
    if ($_GET["delete-mailbox"] == 1) {
        if (is_array($gp->members_array)) {
            $members_array = $gp->members_array;
            while (list($num, $ligne) = each($members_array)) {
                if (trim($num) == null) {
                    continue;
                }
                $sock = new sockets();
                $sock->getFrameWork("cmd.php?DelMbx={$num}");
            }
        }
    }
    if ($_GET["DeleteUsers"] == 1) {
        if (is_array($gp->members_array)) {
            $members_array = $gp->members_array;
            while (list($num, $ligne) = each($members_array)) {
                if (trim($num) == null) {
                    continue;
                }
                $user = new user($num);
                $user->DeleteUser();
            }
        }
    } else {
        $ldap = new clladp();
        $default_dn_nogroup = "cn=nogroup,ou=groups,ou={$ou},dc=organizations,{$ldap->suffix}";
        if (!$ldap->ExistsDN($default_dn_nogroup)) {
            $ldap->AddGroup("nogroup", $group->ou);
        }
        $nogroup_id = $ldap->GroupIDFromName($group->ou, "nogroup");
        if (is_array($gp->members_array)) {
            $members_array = $gp->members_array;
            while (list($num, $val) = each($members_array)) {
                $ldap->AddUserToGroup($nogroup_id, $num);
                $group->DeleteUserFromThisGroup($num);
            }
        }
    }
    $group->Delete();
}
Ejemplo n.º 3
0
function USER_CHANGE_UID_SAVE()
{
    $uid = $_GET["changeuidFrom"];
    $uidnext = $_GET["changeuidTo"];
    $user = new user($uid);
    $array["uid"][0] = $uidnext;
    $ldap = new clladp();
    if (!$ldap->Ldap_modify($user->dn, $array)) {
        echo $ldap->ldap_last_error;
        exit;
    }
    $groups = $user->GetGroups($uid);
    $hash = $user->Groups_list($uid);
    if (is_array($hash)) {
        while (list($num, $val) = each($hash)) {
            $group = new groups($num);
            writelogs("Delete user ({$uid}) from {$val}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
            $group->DeleteUserFromThisGroup($uid);
            $group->AddUsertoThisGroup($uidnext);
        }
    }
    $users = new usersMenus();
    if ($users->POSTFIX_INSTALLED) {
        $sock = new sockets();
        $sock->getFrameWork("cmd.php?postfix-hash-aliases=yes");
    }
}
Ejemplo n.º 4
0
function USER_REMOVE_GROUP()
{
    include_once dirname(__FILE__) . '/ressources/class.user.inc';
    include_once dirname(__FILE__) . '/ressources/class.groups.inc';
    $array = unserialize(base64_decode($value));
    if (!is_array($array)) {
        send_email_events("Failed to unlink user from group, not an array", "", "CLOUD");
        return true;
    }
    $guid = $array["guid"];
    $ou = $array["ou"];
    $uid = $array["uid"];
    events("Get group {$guid} informations {$ou}/{$uid}", __FUNCTION__, __FILE__, __LINE__);
    $group = new groups($guid);
    if ($group->DeleteUserFromThisGroup($uid)) {
        send_email_events("Success to unlink user {$uid} from group {$guid}", "", "CLOUD");
    } else {
        send_email_events("Failed to unlink user {$uid} from group {$guid}", "", "CLOUD");
    }
    sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.artica.meta.users.php --user \"{$uid}\"");
    return true;
}