function users_list()
{
    $tpl = new templates();
    $CurPage = CurrentPageName();
    $search = $_POST["query"];
    $t = $_GET["t"];
    $ad = new external_ad_search($_GET["ConnectionEnc"]);
    if (!is_numeric($_GET["OnlyUsers"])) {
        $_GET["OnlyUsers"] = 0;
    }
    $icon = "user-32.png";
    if ($_GET["OnlyGroups"] == 1) {
        $OnlyGroups = 1;
        $icon = "win7groups-32.png";
        $Array = $ad->flexRTGroups($search, $_POST["rp"]);
        if ($ad->error != null) {
            json_error_show($ad->error, 1);
        }
    }
    if ($_GET["OnlyUsers"] == 1) {
        $OnlyGroups = 0;
        $icon = "win7groups-32.png";
        $Array = $ad->flexRTUsers($search, $_POST["rp"]);
        if ($ad->error != null) {
            json_error_show($ad->error, 1);
        }
    }
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    $members = $tpl->_ENGINE_parse_body("{members}");
    while (list($dn, $itemname) = each($Array)) {
        $GroupxSourceName = $itemname;
        $GroupxName = $itemname;
        $GroupxName = replace_accents($GroupxName);
        $GroupxName = str_replace("'", "`", $itemname);
        $link = "<span style='font-size:14px;'>";
        $addtitile = null;
        $select = null;
        $dn_enc = base64_encode($dn);
        $itemnameenc = base64_encode($itemname);
        $image = imgsimple($icon, null, "PutDN{$t}('{$dn_enc}')");
        $select = imgsimple("arrow-right-24.png", null, "PutDN{$t}('{$dn_enc}')");
        if ($_GET["CallBack"] != null) {
            $select = imgsimple("arrow-right-24.png", null, "YahooSearchUserHide();{$_GET["CallBack"]}('{$dn_enc}','{$itemnameenc}')");
            $image = imgsimple($icon, null, "YahooSearchUserHide();{$_GET["CallBack"]}('{$dn_enc}','{$itemnameenc}')");
        }
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array($image, "<span style='font-size:14px;'>{$link}{$GroupxName}</a>", $select));
    }
    echo json_encode($data);
}