示例#1
0
$auth = new Ldap();
$auth->setLdapAccountBase($ldap_account_base);
$auth->setLdapAccountEmail($ldap_account_email);
$auth->setLdapAccountFullname($ldap_account_full_name);
$auth->setLdapBindType($ldap_bind_type);
$auth->setLdapBindScope($ldap_bind_scope);
$auth->setLdapPassword($ldap_password);
$auth->setLdapUsername($ldap_username);
$auth->setLdapPort($ldap_port);
$auth->setLdapServer($ldap_server);
$auth->setLdapSslVerify($ldap_ssl_verify);
$auth->setLdapStartTls($ldap_start_tls);
$auth->setLdapUserPattern($ldap_user_pattern);
try {
    $username = $auth->getLdapUserAttribute();
    $info = $auth->listAllUsers(array($auth->getLdapUserAttribute(), $ldap_account_full_name, $ldap_account_email), 0);
    if (is_array($info)) {
        for ($i = 0; $i < $info['count']; $i++) {
            $user = @$info[$i][$username][0];
            echo '<tr>';
            echo '<td><input type="checkbox" name="ldapAdminUser[]" value="' . $user . '" /></td>';
            echo '<td>' . $user . '</td>';
            echo '<td>' . @$info[$i][$ldap_account_full_name][0] . '</td>';
            echo '<td>' . @$info[$i][$ldap_account_email][0] . '</td>';
            echo '</tr>';
        }
    }
} catch (Exception $e) {
    error_log($e->getMessage());
    echo '<tr>';
    echo '<td colspan="4">' . $e->getMessage() . '</td>';
示例#2
0
 /**
  * List all users for moderators
  *
  */
 function listUsers()
 {
     $toReturn = "";
     $db = new RecordSet($this->dbConnectionInfo);
     // To protect MySQL injection
     $query = "SELECT * FROM users";
     $db->Open($query);
     $toReturn .= "<table id=\"usersList\" cellpadding='0' cellspacing='0'>";
     $toReturn .= "<thead>";
     $toReturn .= "<tr>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.userName.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.name.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.level.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.company.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.email.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.date.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.notifyAll.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.notifyReply.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.notifyPage.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.status.label');
     $toReturn .= "</td>";
     $toReturn .= "<td>";
     $toReturn .= Utils::translate('admin.user.type');
     $toReturn .= "</td>";
     $toReturn .= "</tr>";
     $toReturn .= "</thead>";
     while ($db->MoveNext()) {
         $user['id'] = $id = $db->Field('userId');
         $user['userName'] = $db->Field('userName');
         $user['name'] = $db->Field('name');
         $user['level'] = $db->Field('level');
         $user['company'] = $db->Field('company');
         $user['email'] = $db->Field('email');
         $user['company'] = $db->Field('company');
         $user['date'] = $db->Field('date');
         $user['notifyAll'] = $db->Field('notifyAll');
         $user['notifyReply'] = $db->Field('notifyReply');
         $user['notifyPage'] = $db->Field('notifyPage');
         $user['status'] = $db->Field('status');
         $user['ldapUser'] = $this->isLdapUser($db->Field('userName')) ? 'LDAP User' : 'Local User';
         $users[] = $user;
         $userNames[] = $user['userName'];
     }
     if ($this->ldap instanceof Ldap) {
         $ldapUsers = array();
         try {
             $uAttribute = $this->ldap->getLdapUserAttribute();
             $ldapUsers = $this->ldap->listAllUsers(array($uAttribute, LDAP_ACCOUNT_EMAIL, LDAP_ACCOUNT_FULLNAME), 0);
         } catch (Exception $e) {
             error_log($e->getMessage());
         }
         $i = 0;
         foreach ($ldapUsers as $key => $user) {
             $i++;
             if ((string) $key != 'count') {
                 $un = $user[$uAttribute][0];
                 if (!in_array($un, $userNames)) {
                     $uName['id'] = 'ldap_' . $un;
                     $uName['userName'] = $un;
                     @($uName['name'] = $user[LDAP_ACCOUNT_FULLNAME][0]);
                     $uName['level'] = 'user';
                     $uName['company'] = '';
                     @($uName['email'] = $user[LDAP_ACCOUNT_EMAIL][0]);
                     $uName['date'] = '';
                     $uName['notifyAll'] = 'no';
                     $uName['notifyReply'] = 'no';
                     $uName['notifyPage'] = 'no';
                     $uName['status'] = 'validated';
                     $uName['ldapUser'] = '******';
                     $users[] = $uName;
                     $userNames[] = $un;
                 }
             }
         }
     }
     foreach ($users as $user) {
         if ($user['userName'] != "anonymous" && $user['id'] != 1) {
             $toReturn .= "<tr id=\"u_" . $user['id'] . "\" onclick='editUser(\"" . $user['id'] . "\")'>";
             $toReturn .= "<td class=\"username\">";
             $toReturn .= $user['userName'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"name\">";
             $toReturn .= $user['name'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"level\">";
             $toReturn .= $user['level'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"company\">";
             $toReturn .= $user['company'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"email\">";
             $toReturn .= $user['email'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"date\">";
             $toReturn .= $user['date'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"notifyAll\">";
             $toReturn .= $user['notifyAll'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"notifyReply\">";
             $toReturn .= $user['notifyReply'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"notifyPage\">";
             $toReturn .= $user['notifyPage'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"status\">";
             $toReturn .= $user['status'];
             $toReturn .= "</td>";
             $toReturn .= "<td class=\"type\">";
             $toReturn .= $user['ldapUser'];
             $toReturn .= "</td>";
             $toReturn .= "</tr>";
         }
     }
     $toReturn .= "</table>";
     return $toReturn;
 }
示例#3
0
     echo "<table class=\"info\">";
     echo "<tr><td>Host </td><td>" . LDAP_SERVER . "</td></tr>";
     echo "<tr><td>Port </td><td>" . LDAP_PORT . "</td></tr>";
     echo "<tr><td>Bind Type </td><td>" . LDAP_BIND_TYPE . "</td></tr>";
     if (LDAP_BIND_TYPE != "anonymous") {
         echo "<tr><td>Username </td><td>" . LDAP_USERNAME . "</td></tr>";
         echo "<tr><td>Password </td><td>" . "*****" . "</td></tr>";
     }
     echo "</table>";
     $continue = false;
 } else {
     // check LDAP lookup
     try {
         $ldap = new Ldap();
         $uAttribute = $ldap->getLdapUserAttribute();
         $ldapUsers = $ldap->listAllUsers(array($uAttribute, LDAP_ACCOUNT_EMAIL, LDAP_ACCOUNT_FULLNAME), 0);
         if (!(is_array($ldapUsers) && $ldapUsers['count'] > 0)) {
             echo "<br/>Could not find LDAP users using specified information:";
             echo "<table class=\"info\">";
             echo "<tr><td>Host </td><td>" . LDAP_SERVER . "</td></tr>";
             echo "<tr><td>Port </td><td>" . LDAP_PORT . "</td></tr>";
             echo "<tr><td>Bind Type </td><td>" . LDAP_BIND_TYPE . "</td></tr>";
             if (LDAP_BIND_TYPE != "anonymous") {
                 echo "<tr><td>Username </td><td>" . LDAP_USERNAME . "</td></tr>";
                 echo "<tr><td>Password </td><td>" . "*****" . "</td></tr>";
             }
             echo "<tr><td>Account Base </td><td>" . LDAP_ACCOUNT_BASE . "</td></tr>";
             echo "<tr><td>User Pattern </td><td>" . LDAP_USER_PATTERN . "</td></tr>";
             echo "</table>";
             $continue = false;
         }