/**
  * Returns the DN who is logged in currently to the given server, which may
  * either be a DN or the string 'anonymous'. This applies only for auth_types
  * "cookie" and "session".
  *
  * One place where this function is used is the tree viewer:
  * After a user logs in, the text "Logged in as: " is displayed under the server
  * name. This information is retrieved from this function.
  *
  * @return string
  * @see have_auth_info
  * @see getLoggedInPass
  */
 function getLoggedInDN()
 {
     # Set default return
     $return = false;
     if ($this->auth_type) {
         switch ($this->auth_type) {
             case 'cookie':
                 $cookie_name = sprintf('pla_login_dn_%s', $this->server_id);
                 if (isset($_COOKIE[$cookie_name])) {
                     $return = pla_blowfish_decrypt($_COOKIE[$cookie_name]);
                 } else {
                     $return = false;
                 }
                 break;
             case 'session':
                 $session_var_name = sprintf('pla_login_dn_%s', $this->server_id);
                 if (isset($_SESSION[$session_var_name])) {
                     $return = pla_blowfish_decrypt($_SESSION[$session_var_name]);
                 } else {
                     $return = false;
                 }
                 break;
             case 'config':
                 $return = $this->login_dn;
                 break;
             default:
                 pla_error(sprintf(_('Unknown auth_type: %s'), htmlspecialchars($auth_type)));
         }
     }
     if (DEBUG_ENABLED) {
         debug_log('%s:getLoggedInDN(): Entered with (), Returning (%s)', 17, get_class($this), $return);
     }
     return $return;
 }
Esempio n. 2
0
    $password = '******';
    foreach (array('md5', 'md5crypt', 'sha', 'ssha', 'smd5', 'crypt', 'clear') as $enc_type) {
        $crypted_password = password_hash($password, $enc_type);
        print "[" . $enc_type . "] " . $crypted_password . "<br />";
        print "  Test: " . (password_check($crypted_password, $password) ? "passed" : "failed");
        print "\n";
        //unset($crypted_password);
        flush();
    }
}
if (true) {
    $secret = "foobar";
    $passwords = array('fun!244A', 'asdf', 'dc=stuff,ou=things', 'y()ikes');
    $passwords_encrypted = array();
    foreach ($passwords as $password) {
        $passwords_encrypted[] = pla_blowfish_encrypt($password, $secret);
    }
    $passwords_decrypted = array();
    foreach ($passwords_encrypted as $password) {
        $passwords_decrypted[] = pla_blowfish_decrypt($password, $secret);
    }
    foreach ($passwords_decrypted as $i => $password) {
        echo $passwords[$i] . ': ' . $passwords_encrypted[$i] . '<br />    ';
        if ($passwords[$i] == $passwords_decrypted[$i]) {
            echo "passed<br />";
        } else {
            echo "<b>failed!</b></br />";
        }
    }
}
print password_generate();