Example #1
0
function find_member()
{
    $tofind = $_GET["find-member"];
    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);
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $cc = new ldapAD();
        $hash = $cc->find_users($ou, $tofind);
    } else {
        $ldap = new clladp();
        $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
        $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
        $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
    }
    $users = new user();
    $number = $hash["count"];
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $html = $html . formatUser($user, $ldap->EnableManageUsersTroughActiveDirectory);
    }
    return $html;
}
Example #2
0
function checksGroups()
{
    $ldap = new ldapAD();
    $sql = "SELECT groupdn FROM activedirectory_groups GROUP BY groupdn";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    echo mysql_num_rows($results) . " groups to parse\n";
    $prefix = "INSERT IGNORE INTO activedirectory_groupsNames (dn,groupname,UsersCount,description) VALUES";
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        //echo $ligne["groupdn"]."\n";
        $hash = $ldap->Ldap_search($ligne["groupdn"], "objectclass=*", array());
        //echo $ligne["groupdn"]."= {$hash["count"]} items\n";
        for ($i = 0; $i < $hash["count"]; $i++) {
            $cn = $hash[$i]["cn"][0];
            $dn = utf8_encode($hash[$i]["dn"]);
            $cn = utf8_encode($cn);
            $UsersCount = $hash[$i]["member"]["count"];
            $description = utf8_encode($hash[$i]["description"][0]);
            $dn = addslashes($dn);
            $cn = addslashes($cn);
            $description = addslashes($description);
            $GLOBALS["MEMORY_COUNT_GROUPS"] = $GLOBALS["MEMORY_COUNT_GROUPS"] + 1;
            $sqli[] = "('{$dn}','{$cn}',{$UsersCount},'{$description}')";
            if (count($sqli) > 500) {
                $sqlfinal = $prefix . " " . @implode(",", $sqli);
                $q->QUERY_SQL($sqlfinal, "artica_backup");
                if (!$q->ok) {
                    echo $q->mysql_error . "\n";
                    return;
                }
                $sqli = array();
            }
        }
    }
    if (count($sqli) > 0) {
        $sqlfinal = $prefix . " " . @implode(",", $sqli);
        $q->QUERY_SQL($sqlfinal, "artica_backup");
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
            return;
        }
        $sql = array();
    }
}
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);
}
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);
}
function users_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        users_list_active_directory();
        return;
    }
    $database = "artica_backup";
    $search = '%';
    $table = "squid_ssl";
    $page = 1;
    $FORCE_FILTER = "AND `type`='ssl-bump-wl'";
    $t = $_GET["t"];
    $sock = new sockets();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (is_base64_encoded($_GET["ou"])) {
        $ou_encoded = $_GET["ou"];
        $ou = base64_decode($_GET["ou"]);
    } else {
        $ou = $_GET["ou"];
        $ou_encoded = base64_encode($_GET["ou"]);
    }
    if ($_SESSION["uid"] != -100) {
        $ou = $_SESSION["ou"];
    }
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
        }
    } else {
        $EnableManageUsersTroughActiveDirectory = 1;
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $hash = $ad->find_users($ou, $tofind);
    }
    $users = new user();
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $uid = $userARR["samaccountname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $img = imgsimple("contact-24.png", null, $js);
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='text-decoration:underline'>";
        $dele = imgsimple("delete-24.png", null, "Loadjs('domains.delete.user.php?uid={$uid}&flexRT={$t}');");
        $data['rows'][] = array('id' => $uid, 'cell' => array($img, "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["sn"][0]} {$userARR["givenname"][0]}</a><div><i>{$userARR["title"][0]}</i></span>", "<span style='font-size:14px;color:{$color}'>{$userARR["telephonenumber"][0]}</span>", "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["mail"][0]}</a></span>", $dele));
    }
    echo json_encode($data);
}
function organization_users_find_member()
{
    $t = time();
    $html = "\n\t<div id='{$t}'></div>\n\t<script>\n\t\tLoadAjax('{$t}','domains.manage.org.findusers.php?ou={$ou}');\n\t</script>\n\t";
    echo $html;
    return;
    $keycached = "{$_GET["finduser"]}{$_GET["ou"]}";
    if (GET_CACHED(__FILE__, __FUNCTION__, $keycached)) {
        return true;
    }
    $sock = new sockets();
    $tofind = $_GET["finduser"];
    $tpl = new templates();
    $page = CurrentPageName();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (is_base64_encoded($_GET["ou"])) {
        $ou_encoded = $_GET["ou"];
        $ou = base64_decode($_GET["ou"]);
    } else {
        $ou = $_GET["ou"];
        $ou_encoded = base64_encode($_GET["ou"]);
    }
    writelogs("Find users {$tofind} in {$ou} (encoded={$_GET["ou"]}) EnableManageUsersTroughActiveDirectory:{$EnableManageUsersTroughActiveDirectory}", __FUNCTION__, __FILE__, __LINE__);
    if ($_SESSION["uid"] != -100) {
        $ou = $_SESSION["ou"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $cc = new ldapAD();
        $hash = $cc->find_users($ou, $tofind);
    } else {
        $ldap = new clladp();
        $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
    }
    $users = new user();
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $bg = "#FFFFFF";
    writelogs("Find users {$tofind} in ou {$ou} DN:\"{$dn}\" (encoded={$_GET["ou"]}) {$number} items", __FUNCTION__, __FILE__, __LINE__);
    $html = "\n\t\n\t\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top'>\n\t\t<div style='width:100%;height:560px;overflow:auto'>\t\n\t\t<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n\t\t<thead class='thead'>\n\t\t\t<tr>\n\t\t\t\t<th colspan=4>{$tofind}</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody class='tbody'>\n\t\t\t\t\n\t";
    $add_user_disabled = Paragraphe('folder-useradd-64-grey.png', '{create_user}', '{create_user_text}');
    $add_user = Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
    $groups = Paragraphe('folder-group-64.png', '{manage_groups}', '{manage_groups_text}', "javascript:Loadjs('domains.edit.group.php?ou={$ou_encoded}&js=yes')", null, 210, 100, 0, true);
    $delete_all_users = Paragraphe('member-64-delete.png', '{delete_all_users}', '{delete_all_users_text}', "javascript:DeleteAllusers()", null, 210, 100, 0, true);
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $delete_all_users = Paragraphe('member-64-delete-grey.png', '{delete_all_users}', '{delete_all_users_text}', "", null, 210, 100, 0, true);
    }
    $usermenus = new usersMenus();
    if ($usermenus->ARTICA_META_ENABLED) {
        if ($sock->GET_INFO("AllowArticaMetaAddUsers") != 1) {
            $add_user = $add_user_disabled;
        }
    }
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $add_user = $add_user_disabled;
    }
    $delete_all_users_warn = $tpl->javascript_parse_text("{delete_all_users_warn}");
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $uid = $userARR["samaccountname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $img = imgtootltip("contact-48.png", "{apply}", $js);
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $html = $html . "<tr class={$classtr}>\n\t\t\t\t\t\t<td width=1% style='font-size:12px'>{$img}</td>\n\t\t\t\t\t\t<td width=50% style='font-size:12px'>{$userARR["sn"][0]} {$userARR["givenname"][0]}<div><i>{$userARR["title"][0]}</i></div></td>\n\t\t\t\t\t\t<td width=1% style='font-size:12px'>{$userARR["telephonenumber"][0]}</td>\n\t\t\t\t\t\t<td width=50% style='font-size:12px' nowrap>{$userARR["mail"][0]}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\n\t\t";
    }
    $html = $html . "</table>\n\t</div>\n\t</td>\n\t<td valign='top' width=1%>{$add_user}<br>{$groups}<br>{$delete_all_users}</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\t\n\tvar X_DeleteAllusers= function (obj) {\n\t\tvar results=trim(obj.responseText);\n\t\tif(results.length>0){alert(results);}\n\t\tLoadAjax('org_user_list','{$page}?finduser=&ou='+escape('{$ou}'));\n\t\t}\t\t\n\n\t\tfunction DeleteAllusers(){\n\t\t\tif(confirm('{$delete_all_users_warn}')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DeleteAllUsersInOu','yes');\n\t\t\tXHR.appendData('ou','{$ou}');\n\t\t\tdocument.getElementById('org_user_list').src='img/wait_verybig.gif';   \t\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_DeleteAllusers);\n\t\t\t}\n\t\t\n\t\t}\n\t\n</script>\t\n\t";
    $html = $tpl->_ENGINE_parse_body($html);
    SET_CACHED(__FILE__, __FUNCTION__, $keycached, $html);
    echo $html;
}
Example #7
0
function ORGANISATIONS_LIST()
{
    $tpl = new templates();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        return ORGANISATIONS_LIST_ACTIVE_DIRECTORY();
    }
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $Mypage = CurrentPageName();
    $users = new usersMenus();
    $sock = new sockets();
    $ou_nozarafa_explain = $tpl->_ENGINE_parse_body("{ou_nozarafa_explain}");
    $t = $_GET["t"];
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $AllowInternetUsersCreateOrg = $sock->GET_INFO("AllowInternetUsersCreateOrg");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        $hash = $ldap->hash_get_ou(true);
    } else {
        $ldap = new clladp();
        $hash = $ldap->hash_get_ou(true);
    }
    if (!is_array($hash)) {
        json_error_show("No data...");
    }
    ksort($hash);
    if ($EnableManageUsersTroughActiveDirectory == 0) {
        if (!$ldap->BuildOrganizationBranch()) {
            json_error_show("{GENERIC_LDAP_ERROR}<br>{$ldap->ldap_last_error}");
        }
    }
    if ($_POST["query"] != null) {
        $search = $_POST["query"];
        $search = str_replace(".", "\\.", $search);
        $search = str_replace("*", ".*?", $search);
    }
    if (isset($_GET["ajaxmenu"])) {
        $ajax = true;
    }
    $pic = "32-environement.png";
    $style = "style='font-size:16px;'";
    $c = 0;
    $ldap2 = new clladp();
    if (count($hash) == 0) {
        json_error_show("no data");
    }
    while (list($num, $ligne) = each($hash)) {
        $ou = $ligne;
        $ou_encoded = base64_encode($ou);
        if (!preg_match("#{$search}#i", $ligne)) {
            writelogs("'{$ligne}' NO MATCH {$search}", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        $md = md5(serialize($hash) . time());
        $md5S = $md;
        $uri = "javascript:Loadjs('domains.manage.org.index.php?js=yes&ou={$ligne}');";
        if ($ajax) {
            $uri = "javascript:Loadjs('{$Mypage}?LoadOrgPopup={$ligne}');";
        }
        $IsOUUnderActiveDirectory = $ldap2->IsOUUnderActiveDirectory($ou);
        $GroupsNB = 0;
        if ($EnableManageUsersTroughActiveDirectory == 0) {
            $img = $ldap->get_organization_picture($ligne, 32);
            writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
            $usersNB = $ldap->CountDeUSerOu($ligne);
            $usersNB = "{$usersNB}";
        } else {
            $img = $pic;
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ad->CountDeUSerOu($ligne);
            } else {
                writelogs("ldap->CountDeUSerOu({$ligne})", __FUNCTION__, __FILE__, __LINE__);
                $usersNB = $ldap->CountDeUSerOu($ligne);
                $usersNB = "{$usersNB}";
            }
        }
        $delete = imgtootltip("delete-32-grey.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>");
        if ($users->AsArticaAdministrator) {
            $delete = Paragraphe('64-cancel.png', "{delete_ou} {$ligne}", '{delete_ou_text}', "javascript:Loadjs('domains.delete.org.php?ou={$ligne}');", null, 210, 100, 0, true);
            $delete = imgsimple("delete-32.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>", "javascript:Loadjs('domains.delete.org.php?ou={$ligne}&t={$t}&id-table={$md5S}');");
        }
        $DomainsNB = $ldap->CountDeDomainsOU($ligne);
        if ($GroupsNB == 0) {
            if ($IsOUUnderActiveDirectory) {
                $ad = new external_ad_search();
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ad->CountDeGroups($ou);
            } else {
                writelogs("->CountDeGroups({$ou})", __FUNCTION__, __FILE__, __LINE__);
                $GroupsNB = $ldap->CountDeGroups($ou);
            }
        }
        Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe('64-folder-group-add.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe("64-folder-group-add.png", "{$ou}:{add_group}", "{add_a_new_group_in_this_org}:<b>{$ou}</b>", "javascript:Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}')");
        $select = imgsimple("domain-32.png", "{manage_organisations_text}", $uri);
        $adduser = imgsimple("folder-useradd-32.png", "{$ou}<hr><b>{create_user}</b><br><i>{create_user_text}</i>", "Loadjs('domains.add.user.php?ou={$ou_encoded}&encoded=yes');");
        $addgroup = imgsimple("32-folder-group-add.png", "{$ou}<hr><b>{add_group}</b><br><i>{add_a_new_group_in_this_org}</i>", "Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}&t={$t}');");
        $SearchUser = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{members}</i>", "Loadjs('domains.find.user.php?ou={$ou_encoded}&encoded=yes');");
        $SearchGroup = imgsimple("loupe-32.png", "{$ou}<hr><b>{search}</b>:<i>{groups}</i>", "Loadjs('domains.find.groups.php?ou={$ou_encoded}&encoded=yes&t={$t}');");
        $searchDomain = imgsimple("loupe-32.png", "{$ou}<hr><b>{localdomains}</b>:<i>{localdomains_text}</i>", "Loadjs('domains.edit.domains.php?js=yes&ou={$ou}&master-t={$t}');");
        $NOZARAFA = 0;
        $OuZarafaText = null;
        if ($IsOUUnderActiveDirectory) {
            $delete = imgtootltip("delete-24-grey.png", "", "");
            $adduser = imgsimple("folder-useradd-32-grey.png");
            $addgroup = imgsimple("32-folder-group-add-grey.png");
        }
        if ($_GET["zarafaF"] == 1) {
            $info = $ldap->OUDatas($ou);
            if (!$info["objectClass"]["zarafa-company"]) {
                $NOZARAFA = 1;
                $OuZarafaText = "<br><a href=\"javascript:blur()\" style='color:#B20808;text-decoration:underline;font-style:italic' \n\t\t\t\tOnClick=\"javascript:Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')\">{$ou_nozarafa_explain}</a>";
            }
        }
        $array = array();
        $array[] = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"{$uri}\" style='font-size:26px;font-weight:bolder;text-transform:capitalize;\n\t\ttext-decoration:underline'>{$ligne}</strong></a>{$OuZarafaText}";
        if ($_GET["zarafaF"] == 1) {
            $zarafaEnabled = "zarafa-logo-32.png";
            if ($NOZARAFA == 1) {
                $zarafaEnabled = "zarafa-logo-32-grey.png";
            }
            $array[] = "<center>" . imgsimple($zarafaEnabled, "<strong style=font-size:26px>{$ou}:{APP_ZARAFA}</strong>\n\t\t\t\t\t<br>{ZARAFA_OU_ICON_TEXT}", "Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}&t={$t}')") . "</center>";
        } else {
            $array[] = "&nbsp;";
        }
        $array[] = "<strong style='font-size:26px'>{$usersNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchUser}</center>";
        $array[] = "<strong style='font-size:26px'>{$GroupsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$SearchGroup}</center>";
        $array[] = "<strong style='font-size:26px'>{$DomainsNB}</strong>";
        $array[] = "<center style='font-size:16px'>{$searchDomain}</center>";
        $array[] = "<center style='font-size:16px'>{$adduser}</center>";
        $array[] = "<center style='font-size:16px'>{$addgroup}</center>";
        $array[] = "<center style='font-size:16px'>{$delete}</center>";
        $c++;
        $data['rows'][] = array('id' => $md5S, 'cell' => $array);
    }
    $total = $c;
    $data['page'] = 1;
    $data['total'] = $total;
    echo json_encode($data);
}
function aliases_ad()
{
    $ldap = new ldapAD();
    $filter = "(&(objectClass=user)(userPrincipalName=*))";
    $attrs = array("userPrincipalName", "mail");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = trim($hash[$i]["mail"][0]);
        $userPrincipalName = trim($hash[$i]["userprincipalname"][0]);
        $GLOBALS["virtual_alias_maps"][$userPrincipalName] = "{$userPrincipalName}\t{$mail}";
    }
}
Example #9
0
function find_member()
{
    if ($_POST["qtype"] == "find-member") {
        $tofind = $_POST["query"];
    }
    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;
    }
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
            $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
        }
    } else {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $p = new external_ad_search();
        $hash = $p->find_users($ou, $tofind);
        $ldap->EnableManageUsersTroughActiveDirectory = true;
    }
    $users = new user();
    $number = $hash["count"];
    $data = array();
    $data['page'] = 0;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $data['rows'][] = formatUser($user, $ldap->EnableManageUsersTroughActiveDirectory);
    }
    echo json_encode($data);
}
Example #10
0
function users_search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        users_search_directory();
        return;
    }
    $page = 1;
    $t = $_GET["t"];
    $sock = new sockets();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (is_base64_encoded($_GET["ou"])) {
        $ou_encoded = $_GET["ou"];
        $ou = base64_decode($_GET["ou"]);
    } else {
        $ou = $_GET["ou"];
        $ou_encoded = base64_encode($_GET["ou"]);
    }
    if ($_SESSION["uid"] != -100) {
        $ou = $_SESSION["ou"];
    }
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
        }
    } else {
        $EnableManageUsersTroughActiveDirectory = 1;
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $hash = $ad->find_users($ou, $tofind);
    }
    $boot = new boostrap_form();
    $users = new user();
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    $styleTD = " style='font-size:16px'";
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $uid = $userARR["samaccountname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $dele = imgsimple("delete-24.png", null, "Loadjs('domains.delete.user.php?uid={$uid}&flexRT={$t}');");
        $link = $boot->trswitch($js);
        $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$styleTD} width=99% nowrap {$link}><i class='icon-user'></i>&nbsp;{$userARR["sn"][0]} {$userARR["givenname"][0]}<div><i>{$userARR["title"][0]}</i></td>\n\t\t<td {$styleTD} width=99% nowrap {$link}>{$userARR["telephonenumber"][0]}</td>\n\t\t<td {$styleTD} width=99% nowrap {$link}>{$userARR["mail"][0]}</td>\n\t\t<td width=35px align='center' nowrap>{$dele}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t\t<th>{phone}</th>\n\t\t\t\t\t<th>{email}</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t\t\t</table>";
}
Example #11
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";
}
Example #12
0
function ORGANISATIONS_LIST()
{
    $page = CurrentPageName();
    $search = $_GET["search"];
    if ($search == null) {
        $search = "*";
    }
    if (strpos("  {$search}", "*") == 0) {
        $search = $search . "*";
    }
    $users = new usersMenus();
    $sock = new sockets();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    $AllowInternetUsersCreateOrg = $sock->GET_INFO("AllowInternetUsersCreateOrg");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $ldap = new ldapAD();
        $hash = $ldap->hash_get_ou(true);
    } else {
        $ldap = new clladp();
        $hash = $ldap->hash_get_ou(true);
    }
    if (!is_array($hash)) {
        return null;
    }
    ksort($hash);
    if ($EnableManageUsersTroughActiveDirectory == 0) {
        if (!$ldap->BuildOrganizationBranch()) {
            $error = "<div style='float:left'>" . Paragraphe("danger64.png", "{GENERIC_LDAP_ERROR}", $ldap->ldap_last_error) . "</div>";
        }
    }
    $page = CurrentPageName();
    if (isset($_GET["ajaxmenu"])) {
        $header = "\n\t<input type='hidden' name='add_new_organisation_text' id='add_new_organisation_text' value='{add_new_organisation_text}'>\n\t<input type='hidden' name='ajaxmenu' id='ajaxmenu' value='yes'>";
    }
    $add = butadm();
    $html = "\n\t{$header}\n\t{$error}<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th width=1%>{$add}</th>\n\t\t<th>{organizations}</th>";
    if ($users->ZARAFA_INSTALLED) {
        if ($users->AsMailBoxAdministrator) {
            $html = $html . "<th>Zarafa</th>";
        }
    }
    $html = $html . "<th colspan=2>{users}</th>\n\t\t<th colspan=2>{groups}</th>\n\t\t<th>{domains}</th>\n\t\t<th>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    if (isset($_GET["ajaxmenu"])) {
        $ajax = true;
    }
    $pic = "32-environement.png";
    $search = str_replace(".", "\\.", $search);
    $search = str_replace("*", ".*?", $search);
    $style = "style='font-size:16px;'";
    while (list($num, $ligne) = each($hash)) {
        $ou = $ligne;
        $ou_encoded = base64_encode($ou);
        if (!preg_match("#{$search}#i", $ligne)) {
            writelogs("'{$ligne}' NO MATCH {$search}", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        $md = md5($ligne);
        $uri = "javascript:Loadjs('domains.manage.org.index.php?js=yes&ou={$ligne}');";
        if ($ajax) {
            $uri = "javascript:Loadjs('{$page}?LoadOrgPopup={$ligne}');";
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        Paragraphe($img, "{manage} {$ligne}", "<strong>{$ligne}:{$usersNB}<br></strong>{manage_organisations_text}", $uri, null);
        if ($EnableManageUsersTroughActiveDirectory == 0) {
            $img = $ldap->get_organization_picture($ligne, 32);
            $usersNB = $ldap->CountDeUSerOu($ligne);
            $usersNB = "{$usersNB}";
        } else {
            $img = $pic;
            $usersNB = $ldap->CountDeUSerOu($ligne);
            $usersNB = "{$usersNB}";
        }
        $delete = imgtootltip("delete-32-grey.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>");
        if ($users->AsArticaAdministrator) {
            $delete = Paragraphe('64-cancel.png', "{delete_ou} {$ligne}", '{delete_ou_text}', "javascript:Loadjs('domains.delete.org.php?ou={$ligne}');", null, 210, 100, 0, true);
            $delete = imgtootltip("delete-32.png", "<b>{delete_ou} {$ligne}</b><br><i>{delete_ou_text}</i>", "javascript:Loadjs('domains.delete.org.php?ou={$ligne}');");
        }
        if ($users->ZARAFA_INSTALLED) {
            if ($users->AsMailBoxAdministrator) {
                Paragraphe("zarafa-logo-64.png", "{$ou}:{APP_ZARAFA}", "{ZARAFA_OU_ICON_TEXT}", "javascript:Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}')", null, 210, 100, 0, true);
                $info = $ldap->OUDatas($ou);
                $zarafaEnabled = "zarafa-logo-32.png";
                if (!$info["objectClass"]["zarafa-company"]) {
                    $zarafaEnabled = "zarafa-logo-32-grey.png";
                }
                $zarafa = "<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>" . imgtootltip($zarafaEnabled, "<b>{$ou}:{APP_ZARAFA}</b><br>{ZARAFA_OU_ICON_TEXT}", "Loadjs('domains.edit.zarafa.php?ou={$ou_encoded}')") . "</td>";
            }
        }
        $DomainsNB = $ldap->CountDeDomainsOU($ligne);
        $GroupsNB = $ldap->CountDeGroups($ou);
        Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe('64-folder-group-add.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
        Paragraphe("64-folder-group-add.png", "{$ou}:{add_group}", "{add_a_new_group_in_this_org}:<b>{$ou}</b>", "javascript:Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}')");
        $select = imgtootltip($img, "{manage_organisations_text}", $uri);
        $adduser = imgtootltip("folder-useradd-32.png", "<b>{create_user}</b><br><i>{create_user_text}</i>", "Loadjs('domains.add.user.php?ou={$ou_encoded}&encoded=yes');");
        $addgroup = imgtootltip("32-folder-group-add.png", "<b>{add_group}</b><br><i>{add_a_new_group_in_this_org}</i>", "Loadjs('domains.edit.group.php?popup-add-group=yes&ou={$ou}');");
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1% {$style} nowrap>{$select}</td>\n\t\t\t<td width=99% {$style} nowrap><a href=\"javascript:blur();\" OnClick=\"{$uri}\" style='font-size:18px;font-weight:bolder;text-transform:capitalize;text-decoration:underline'>{$ligne}</strong></a></td>\n\t\t\t{$zarafa}\n\t\t\t<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>{$usersNB}</strong></td>\n\t\t\t<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>{$adduser}</strong></td>\n\t\t\t<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>{$GroupsNB}</strong></td>\n\t\t\t<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>{$addgroup}</strong></td>\n\t\t\t<td width=1% {$style} nowrap align='center'><strong style='font-size:16px'>{$DomainsNB}</strong></td>\n\t\t\t<td width=1%>{$delete}</td>\n\t\t</tr>";
    }
    $pic = "32-environement.png";
    if ($AllowInternetUsersCreateOrg == 1) {
        $sql = "SELECT * FROM register_orgs WHERE sended=0 ORDER BY ou";
        $q = new mysql();
        $results = $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            echo "<H2>{$q->mysql_error}</H2>";
        }
        while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
            if ($classtr == "oddRow") {
                $classtr = null;
            } else {
                $classtr = "oddRow";
            }
            $uri = "javascript:Loadjs('domains.organizations.parameters.php?ou-sql-js={$ligne["zmd5"]}')";
            Paragraphe("img/org-warning-64.png", "{$name}", "<strong>{$time}:<br></strong>{waiting}", $uri);
            $name = $ligne["ou"];
            $time = $ligne["register_date"];
            $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1% {$style} nowrap>{$select}</td>\n\t\t\t<td width=99% {$style} nowrap><strong style='font-size:16px'>{$ligne}</strong></td>\n\t\t\t<td width=1% {$style} nowrap><strong style='font-size:16px'>-</strong></td>\n\t\t\t<td width=1%>{$delete}</td>\n\t\t</tr>";
        }
    }
    $html = $html . "</tbody></table>";
    if ($users->POSTFIX_INSTALLED) {
        Buildicon64('DEF_ICO_SENDTOALL', 220, 100);
    }
    if ($EnableManageUsersTroughActiveDirectory == 0) {
        $ldap->ldap_close();
    }
    return "{$parameters}" . $html . "{$sendmail}</div>\n\t<script>\n\tOrgfillpageButton();\n\t</script>\n\t\n\t";
}