function users_search_directory()
{
    $database = "artica_backup";
    $search = '%';
    $table = "squid_ssl";
    $page = 1;
    $FORCE_FILTER = "AND `type`='ssl-bump-wl'";
    $t = $_GET["t"];
    $dn = urldecode($_GET["dn"]);
    $sock = new sockets();
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    if (strpos($dn, ",") > 0) {
        $ou = $dn;
    }
    include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
    $ad = new external_ad_search();
    $hash = $ad->find_users($ou, $tofind, $_POST['rp']);
    $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];
        $dn = null;
        $uid = $userARR["uid"][0];
        if (isset($userARR["samaccountname"][0])) {
            $uid = $userARR["samaccountname"][0];
        }
        if (isset($userARR["distinguishedname"][0])) {
            $dn = $userARR["distinguishedname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1, $dn);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = $userARR["sn"][0];
        $givenname = $userARR["givenname"][0];
        $title = $userARR["title"][0];
        $mail = $userARR["mail"][0];
        $telephonenumber = $userARR["telephonenumber"][0];
        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 = "&nbsp;";
        $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);
}
Exemple #2
0
function query_members_ad()
{
    include_once dirname(__FILE__) . '/class.external.ad.inc';
    $sock = new sockets();
    $config = unserialize(base64_decode($sock->GET_INFO("SambaAdInfos")));
    $ldap = new external_ad_search($config);
    $query = $_POST["query"];
    if ($query == null) {
        $query = "*";
    }
    $hash = $ldap->find_users(null, $query, $_POST["rp"]);
    writelogs("COUNT={$hash["count"]}", __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = 1;
    $data['total'] = $hash["count"];
    $data['rows'] = array();
    $c = 0;
    for ($i = 0; $i < $hash["count"]; $i++) {
        $ligne = $hash[$i];
        $samaccountname = $ligne["samaccountname"][0];
        if ($samaccountname == null) {
            continue;
        }
        $gid = 0;
        $Displayname = $samaccountname;
        $img = "user-18.png";
        $prepend = "user:"******"NOComputers"] == 1) {
                continue;
            }
            $Displayname = str_replace('$', '', $Displayname);
            $img = "base.gif";
            $prepend = "computer:";
        }
        $js = "SambaBrowseSelect('{$samaccountname}','{$prepend}',{$gid})";
        if ($_GET["callback"] != null) {
            $js = "{$_GET["callback"]}('{$samaccountname}','{$prepend}',{$gid})";
        }
        if (isset($ligne["displayname"][0])) {
            $Displayname = $ligne["displayname"][0];
        }
        $c++;
        if ($c > $_POST["rp"]) {
            break;
        }
        $data['rows'][] = array('id' => md5(serialize($ligne["displayname"])), 'cell' => array("<img src='img/{$img}'>", "<span style='font-size:14px;font-weight:bolder'>{$Displayname}</span> <span style='font-size:11px'>({$samaccountname})</span>", "<span style='font-size:14px'>" . imgsimple("arrow-right-24.png", "{add}", $js) . "</span>"));
    }
    $data['total'] = $c;
    echo json_encode($data);
}
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);
}