コード例 #1
0
function LIST_GROUPS_FROM_OU_search()
{
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        LIST_GROUPS_FROM_OU_search_ActiveDirectory();
        return;
    }
    if ($_POST["query"] != null) {
        $search = $_POST["query"];
    }
    $GLOBALS["NOUSERSCOUNT"] = false;
    $ou = base64_decode($_GET["ou"]);
    $sock = new sockets();
    $page = CurrentPageName();
    $tpl = new templates();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = 0;
    $data['rows'] = array();
    writelogs("[{$search}]: EnableManageUsersTroughActiveDirectory = {$EnableManageUsersTroughActiveDirectory} ", __FUNCTION__, __FILE__);
    $ldap = new clladp();
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $GLOBALS["NOUSERSCOUNT"] = true;
            $ldap = new ldapAD();
            writelogs("[{$search}]: ->hash_get_groups_from_ou_mysql({$ou},{$search}) ", __FUNCTION__, __FILE__);
            $hash = $ldap->hash_get_groups_from_ou_mysql($ou, $search, true);
        } else {
            $ldap = new clladp();
            $hash = $ldap->hash_groups($ou, 1);
        }
    } else {
        $GLOBALS["NOUSERSCOUNT"] = true;
        $EnableManageUsersTroughActiveDirectory = 1;
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $hash = $ad->hash_groups($ou);
    }
    $tr = array();
    $search = str_replace(".", '\\.', $search);
    $search = str_replace("*", '.*?', $search);
    if (!is_array($hash)) {
        json_error_show("No group");
    }
    $c = 0;
    while (list($num, $line) = each($hash)) {
        if (strtolower($line) == 'default_group') {
            continue;
        }
        if (strlen($search) > 2) {
            if (!preg_match("#{$search}#", $line)) {
                continue;
            }
        }
        $color = "black";
        $lineEnc = urlencode($line);
        $js = "javascript:Loadjs('domains.edit.group.tabs.php?gid={$num}&name={$lineEnc}&ou={$_GET["ou"]}&encoded=yes')";
        if (!$GLOBALS["NOUSERSCOUNT"]) {
            $gp = new groups($num);
            $members = count($gp->members_array);
            $text = $tpl->_ENGINE_parse_body("{manage_this_group}");
            if ($gp->description != null) {
                $text == $tpl->_ENGINE_parse_body($gp->description);
            }
            $c++;
            $data['rows'][] = array('id' => md5($line), 'cell' => array("<span style='font-size:14px;color:{$color};'><img src='img/group-24.png'></span>", "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-size:14px;color:{$color};text-decoration:underline'>{$line}</a>", "<span style='font-size:14px;color:{$color};'>{$members}</span>", "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-size:14px;color:{$color};text-decoration:underline'>{$text}</a>"));
        } else {
            $text = "{manage_this_group}";
            if (is_array($line)) {
                $members = $line["UsersCount"];
                $text = $tpl->_ENGINE_parse_body("{manage_this_group}");
                if ($line["description"] != null) {
                    $text = $tpl->_ENGINE_parse_body($line["description"]);
                }
                $c++;
                $data['rows'][] = array('id' => md5($line["groupname"]), 'cell' => array("<span style='font-size:14px;color:{$color};'><img src='img/group-24.png'></span>", "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-size:14px;color:{$color};text-decoration:underline'>{$line["groupname"]}</span>", "<span style='font-size:14px;color:{$color};'>{$members}</span>", "<span style='font-size:14px;color:{$color};'>{$text}</span>"));
            } else {
                $c++;
                $data['rows'][] = array('id' => md5($line), 'cell' => array("<span style='font-size:14px;color:{$color};'><img src='img/group-24.png'></span>", "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-size:14px;color:{$color};text-decoration:underline'>{$line}</span>", "<span style='font-size:14px;color:{$color};'>{$members}</span>", "<span style='font-size:14px;color:{$color};'>{$text}</span>"));
            }
        }
    }
    $data['total'] = $c;
    echo json_encode($data);
}
コード例 #2
0
function find_member()
{
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        find_member_active_directory();
        return;
    }
    if ($_POST["qtype"] == "find-member") {
        $tofind = $_POST["query"];
    }
    $t = $_GET["t"];
    $tt = $_GET["tt"];
    if ($_SESSION["uid"] == -100) {
        $ou = $_GET["ou"];
    } else {
        $ou = $_SESSION["ou"];
    }
    $sock = new sockets();
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace('***', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $tofind = str_replace(".", '\\.', $tofind);
    $tofind = str_replace("*", '.*?', $tofind);
    $ldap = new clladp();
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $GLOBALS["NOUSERSCOUNT"] = true;
            $ldap = new ldapAD();
            writelogs("[{$tofind}]: ->hash_get_groups_from_ou_mysql({$ou},{$tofind}) ", __FUNCTION__, __FILE__);
            $hash = $ldap->hash_get_groups_from_ou_mysql($ou, $tofind, true);
        } else {
            $ldap = new clladp();
            $hash = $ldap->hash_groups($ou, 1);
        }
    } else {
        $hash = find_member_active_directory();
        $ldap->EnableManageUsersTroughActiveDirectory = true;
        $GLOBALS["NOUSERSCOUNT"] = true;
    }
    $number = count($hash);
    $data = array();
    $data['page'] = 0;
    $data['total'] = $number;
    $data['rows'] = array();
    $styla = "style='font-size:14px;text-decoration:underline;font-weight:bold'";
    $styleNum = "style='font-size:16px;font-weight:bold'";
    $search = string_to_flexregex();
    if (is_array($hash)) {
        while (list($num, $line) = each($hash)) {
            if (strtolower($line) == 'default_group') {
                continue;
            }
            if (strlen($search) > 2) {
                if (!preg_match("#{$search}#", $line)) {
                    continue;
                }
            }
            $text = null;
            $js = "javascript:Loadjs('domains.edit.group.php?js=yes&group-id={$num}&ou={$_GET["ou"]}&encoded=yes&tt={$t}&ttt={$tt}')";
            $delete = imgsimple("delete-24.png", "{delete} {$num}", "Loadjs('domains.delete.group.php?gpid={$num}')");
            if (!$GLOBALS["NOUSERSCOUNT"]) {
                $delete = "&nbsp;";
                $gp = new groups($num);
                $members = count($gp->members_array);
                if ($gp->description != null) {
                    $text = $gp->description;
                }
                $data['rows'][] = array('id' => $line, 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line}</a>", "<span {$styleNum}>{$members}</span>", "<span style='font-size:14px'>{$text}</span>", $delete));
            } else {
                if (is_array($line)) {
                    if ($line["description"] != null) {
                        $text = $line["description"];
                    }
                    if (strlen($search) > 2) {
                        if (!preg_match("#{$search}#", $line["groupname"])) {
                            continue;
                        }
                    }
                    if (!is_numeric($line["gid"])) {
                        $delete = imgsimple("delete-24-grey.png");
                    }
                    $js = "javascript:Loadjs('domains.edit.group.php?js=yes&group-id={$line["gid"]}&ou={$_GET["ou"]}&encoded=yes&tt={$t}&ttt={$tt}')";
                    $data['rows'][] = array('id' => md5($line["groupname"]), 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line["groupname"]}</a>", "<span {$styleNum}>{$line["UsersCount"]}</span>", "<span style='font-size:14px'>{$text}</span>", $delete));
                } else {
                    $data['rows'][] = array('id' => $line, 'cell' => array("<a href=\"javascript:blur();\" OnClick=\"{$js}\" {$styla}>{$line}</a>", "<span {$styleNum}>?</span>", "<span style='font-size:14px'></span>", $delete));
                }
            }
        }
    }
    echo json_encode($data);
}
コード例 #3
0
function LIST_GROUPS_FROM_OU_search()
{
    $search = $_GET["search"];
    $GLOBALS["NOUSERSCOUNT"] = false;
    $ou = base64_decode($_GET["ou"]);
    $sock = new sockets();
    $page = CurrentPageName();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    writelogs("[{$search}]: EnableManageUsersTroughActiveDirectory = {$EnableManageUsersTroughActiveDirectory} ", __FUNCTION__, __FILE__);
    $addgroup = Paragraphe("64-folder-group-add.png", "{add_group}", "{add_a_new_group_in_this_org}", "javascript:Loadjs('{$page}?popup-add-group=yes&ou={$_GET["ou"]}')");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $GLOBALS["NOUSERSCOUNT"] = true;
        $addgroup = Paragraphe("64-folder-group-add-grey.png", "{add_group}", "{add_a_new_group_in_this_org}", "");
        $ldap = new ldapAD();
        writelogs("[{$search}]: ->hash_get_groups_from_ou_mysql({$ou},{$search}) ", __FUNCTION__, __FILE__);
        $hash = $ldap->hash_get_groups_from_ou_mysql($ou, $search, true);
    } else {
        $ldap = new clladp();
        $hash = $ldap->hash_groups($ou, 1);
    }
    $tr = array();
    $search = str_replace(".", '\\.', $search);
    $search = str_replace("*", '.*?', $search);
    $tr[] = $addgroup;
    if (is_array($hash)) {
        while (list($num, $line) = each($hash)) {
            if (strtolower($line) == 'default_group') {
                continue;
            }
            if (strlen($search) > 2) {
                if (!preg_match("#{$search}#", $line)) {
                    continue;
                }
            }
            $js = "javascript:LoadAjax('GroupSettings','domains.edit.group.php?LoadGroupSettings={$num}&ou={$_GET["ou"]}&encoded=yes')";
            if (!$GLOBALS["NOUSERSCOUNT"]) {
                $gp = new groups($num);
                $members = count($gp->members_array);
                $text = "{manage_this_group}<br>({$members} {members})";
                if ($gp->description != null) {
                    $text = $gp->description . "<br>({$members} {members})";
                }
                $tr[] = Paragraphe("group-64.png", $line, $text, $js);
            } else {
                $text = "{manage_this_group}";
                if (is_array($line)) {
                    $text = "{manage_this_group}<br>({$line["UsersCount"]} {members})";
                    if ($line["description"] != null) {
                        $text = $line["description"] . "<br>({$line["UsersCount"]} {members})";
                    }
                    $tr[] = Paragraphe("group-64.png", $line["groupname"], $text, $js);
                } else {
                    $tr[] = Paragraphe("group-64.png", $line, $text, $js);
                }
            }
        }
    }
    $tables[] = "<table style='width:100%'><tr>";
    $t = 0;
    while (list($key, $line) = each($tr)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        $t = $t + 1;
        $tables[] = "<td valign='top'>{$line}</td>";
        if ($t == 3) {
            $t = 0;
            $tables[] = "</tr><tr>";
        }
    }
    if ($t < 3) {
        for ($i = 0; $i <= $t; $i++) {
            $tables[] = "<td valign='top'>&nbsp;</td>";
        }
    }
    echo @implode("\n", $tables) . "</table>\n";
}