예제 #1
0
 static function validate_login_ntlm($username, $password)
 {
     if (!function_exists("java_get_base")) {
         require "lib/java/java.php";
     }
     if (!function_exists("java_require")) {
         sys_log_message_alert("login", sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "PHP/Java Bridge"));
         return false;
     }
     java_require("jcifs-1.3.8_tb.jar");
     $conf = new JavaClass("jcifs.Config");
     $conf->setProperty("jcifs.smb.client.responseTimeout", "5000");
     $conf->setProperty("jcifs.resolveOrder", "LMHOSTS,DNS");
     $conf->setProperty("jcifs.smb.client.soTimeout", "10000");
     $conf->setProperty("jcifs.smb.lmCompatibility", "0");
     $conf->setProperty("jcifs.smb.client.useExtendedSecurity", false);
     $auth = sys_get_header("Authorization");
     $session = new JavaClass("jcifs.smb.SmbSession");
     $result = new Java("jcifs.smb.NtlmPasswordAuthentication", "", $username, $password);
     $username = $result->getUsername();
     if (SETUP_AUTH_NTLM_SHARE) {
         $w = new Java("jcifs.smb.SmbFile", SETUP_AUTH_NTLM_SHARE, $result);
         $message = $w->canListFiles();
         if ($message == "Invalid access to memory location.") {
             header("Location: index.php");
             exit;
         }
     } else {
         $message = $session->logon(SETUP_AUTH_HOSTNAME_NTLM, $result);
     }
     if ($message != "" or $username == "") {
         sys_log_message_alert("login", sprintf("{t}Login failed from %s.{/t} (ntlm) ({t}Username{/t}: %s, %s)", _login_get_remoteaddr(), $username, $message));
         return false;
     }
     $_SERVER["REMOTE_USER"] = modify::strip_ntdomain($username);
     if (empty($_REQUEST["folder"])) {
         $_REQUEST["redirect"] = 1;
     }
     return true;
 }