Esempio n. 1
0
function popup_search()
{
    $icon = "win7groups-32.png";
    $ad = new external_ad_search();
    if ($_POST["query"] == null) {
        $_POST["query"] = "*";
    }
    if (strpos(" {$_POST["query"]}", "*") == 0) {
        $_POST["query"] = "*{$_POST["query"]}*";
    }
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $Array = $ad->HashUsersFromGroupDN(base64_decode($_GET["DN"]), false, true);
    ksort($Array);
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    if ($_POST["query"] != null) {
        $searchstring = str_replace("*", ".*?", $searchstring);
    }
    $c = 0;
    while (list($UserName, $itemname) = each($Array)) {
        if ($c > $_POST["rp"]) {
            break;
        }
        if ($searchstring != null) {
            if (!preg_match("#{$searchstring}#", $UserName)) {
                continue;
            }
        }
        $c++;
        $image = imgsimple($icon, null, $js);
        $select = imgsimple("arrow-right-32.png", null, $js);
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array("<center><img src=img/user-32.png></center>", "<span style='font-size:20px;'>{$UserName}</a></span>"));
    }
    echo json_encode($data);
}
Esempio n. 2
0
function MEMBERS_LIST_LIST($gid = 0)
{
    $sock = new sockets();
    $tpl = new templates();
    $page = CurrentPageName();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if ($gid == "undefined") {
        $gid = 0;
    }
    if (isset($_GET["gpid"])) {
        $gid = $_GET["gpid"];
    }
    $priv = new usersMenus();
    if ($_POST["query"] != null) {
        $search = $_POST["query"];
    }
    if (strpos($gid, ',') > 0) {
        writelogs("-> HashUsersFromGroupDN({$gid})", __FUNCTION__, __FILE__, __LINE__);
        $p = new external_ad_search();
        $members = $p->HashUsersFromGroupDN($gid);
        $count = count($members);
        writelogs("found {$count} members for DN ({$gid})", __FUNCTION__, __FILE__, __LINE__);
        $EnableManageUsersTroughActiveDirectory = true;
    } else {
        writelogs("-> groups({$gid},{$search})", __FUNCTION__, __FILE__, __LINE__);
        $group = new groups($gid, $search);
        writelogs("-> groups({$gid},{$search}) END", __FUNCTION__, __FILE__, __LINE__);
        $members = $group->members;
        $count = count($members);
        $EnableManageUsersTroughActiveDirectory = $group->EnableManageUsersTroughActiveDirectory;
        writelogs("found {$count} members for (gidnumber={$gid})", __FUNCTION__, __FILE__, __LINE__);
    }
    $search = str_replace(".", '\\.', $search);
    $search = str_replace("*", ".*?", $search);
    $count = count($members);
    $number_of_users = $count;
    if (!is_array($members)) {
        json_error_show("No Members {$search}...");
    }
    $user_img = "user-32.png";
    $computer_img = "computer-32.png";
    $classtr = null;
    $img = null;
    $already = array();
    $data = array();
    $data['page'] = $_POST["page"];
    $data['total'] = $number_of_users;
    $data['rows'] = array();
    $c = 0;
    $Page = $_POST["page"];
    if (!is_numeric($Page)) {
        $Page = 1;
    }
    $start = 0;
    $stop = $_POST["rp"];
    $Page = $Page - 1;
    if ($Page > 0) {
        $start = $Page * $_POST["rp"];
        $stop = $start + $_POST["rp"];
    }
    if (!is_numeric($stop)) {
        $stop = 50;
    }
    writelogs("groups: starting table i={$start} to {$stop}", __FUNCTION__, __FILE__, __LINE__);
    for ($i = $start; $i <= $stop; $i++) {
        $uid = $members[$i];
        if (trim($uid) == null) {
            continue;
        }
        $color = "black";
        if (substr($uid, strlen($uid) - 1, 1) == '$') {
            $img = $computer_img;
        } else {
            $img = $user_img;
        }
        $md = md5($uid);
        if (isset($already[$uid])) {
            continue;
        }
        $delete = imgsimple('delete-24.png', '{disconnect_from_this_group}', "DeleteUserFromGroup('{$uid}','{$md}')");
        if ($EnableManageUsersTroughActiveDirectory) {
            $delete = imgsimple('delete-24-grey.png', '{disconnect_from_this_group}', "");
        }
        $already[$uid] = true;
        if (strlen($search) > 0) {
            if (!preg_match("#{$search}#", $uid)) {
                continue;
            }
        }
        $link = MEMBER_JS($uid, 1, 1);
        $data['rows'][] = array('id' => "uidG{$md}", 'cell' => array("<span style='font-size:14px;color:{$color}'><img src='img/{$img}'></span>", "<span style='font-size:14px;color:{$color}'><a href=\"javascript:blur();\" OnClick=\"javascript:{$link}\" style='font-size:14px;text-decoration:underline'>{$uid}</a></span>", "<span style='font-size:14px;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Esempio n. 3
0
function ActiveDirectoryCache($PATTERN)
{
    $MASTERKEY = md5($PATTERN);
    $CacheTime = round($GLOBALS["PARAMS"]["CACHE_TIME"] / 60);
    if ($CacheTime == 0) {
        $CacheTime = 6;
        $GLOBALS["PARAMS"]["CACHE_TIME"] = $CacheTime * 60;
    }
    if (isset($GLOBALS["AD"][$MASTERKEY])) {
        if (isset($GLOBALS["AD"][$MASTERKEY]["TIME"])) {
            $data1 = $GLOBALS["AD"][$MASTERKEY]["TIME"];
            if (!is_numeric($data1)) {
                $data1 = 0;
            }
            $data2 = time();
            $difference = $data2 - $data1;
            $mins = round($difference / 60);
            if ($mins < $CacheTime) {
                return $GLOBALS["AD"][$MASTERKEY]["DB"];
            }
        }
    }
    $ad = new external_ad_search();
    $members = $ad->HashUsersFromGroupDN($PATTERN);
    if ($GLOBALS["DEBUG_LEVEL"] > 1) {
        WLOG("ActiveDirectoryCache(): {$PATTERN} = " . count($members) . " members");
    }
    if (count($members) == 0) {
        $GLOBALS["AD"][$MASTERKEY]["TIME"] = time();
        $GLOBALS["AD"][$MASTERKEY]["DB"] = array();
        return array();
    }
    while (list($index, $uid) = each($members)) {
        $uid = trim(strtolower($uid));
        if ($uid == null) {
            continue;
        }
        if ($GLOBALS["DEBUG_LEVEL"] > 1) {
            WLOG("ActiveDirectoryCache(): {$uid} member");
        }
        $GLOBALS["AD"][$MASTERKEY]["TIME"] = time();
        $GLOBALS["AD"][$MASTERKEY]["DB"][$uid] = true;
    }
    return $GLOBALS["AD"][$MASTERKEY]["DB"];
}