Esempio n. 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;
}
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;
}
Esempio n. 4
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);
}
Esempio n. 5
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>";
}