A few days ago in the question and answer area raised this question, all of the friends who answered the question said that it is impossible to achieve through PHP, it happened that my intern responsible for me to find a way, seemingly through the implementation of NTLM, I am a novice, on the specific principle also known unknown, just own test, very useful.
So take it out and share it with you. This is written by a Frenchman, so the comments in the code are in French, and if a friend wants to know the meaning of the comment on a line, please post it, I can try to translate it.
<?php/***************************************************************************************************** PHP NTLM GET LOGIN * Version 0.2.1 * Copyright (c) 2004 Nico Las gollet (dot) gollet (at) secusquad (dot) com) * Copyright (c) 2004 Flextronics saint-etienne** is free software. Can redistribute it and/or modify * it under the terms of the GNU general public License as published by * the Ftware Foundation; Either version 2 of the License. /session_start (); $headers = apache_ Request_headers (); Gets the user header if (@$_server[' Http_via ']! = NULL) {//confirms that the proxy is used because NTLM authentication cannot pass through the proxy. echo "proxy bypass!";} ElseIf ($headers [' Authorization '] = = NULL) {//si l ' entete autorisation est inexistante if the license header does not exist header ("http/1.0 401 Unaut Horized "); Envoi au client le mode d ' identification header ("WWW-AUTHENTICATE:NTLM"); Dans noTre cas le NTLM exit; On Quitte}if (Isset ($headers [' Authorization '))//dans le cas d ' une authorisation (identification) {if (substr ($header s[' Authorization '],0,5) = = ' NTLM ') {//Verify that the client is under NTLM $chaine = $headers [' Authorization ']; $chaine =substr ($chaine, 5); Get base64-encoded type1 information $chained 64=base64_decode ($chaine); Decode Base64 to $chained if (Ord ($chained 64{8}) = = 1) {//|_ byte signifiant l ' etape du processus d ' identificatio N (Etape 3)//Verification du drapeau NTLM "0xb2"? l ' offset dans le message type-1-message (comp ie 5.5+): if (or D ($chained 64[13])! = 178) {echo "NTLM Flag error!"; Exit } $retAuth = "NTLMSSP". Chr (002). Chr (ON) Chr. chr (ON) Chr. CHR (000); (a); $retAuth. = Chr (040). chr (ON) Chr. CHR (001). Chr (() Chr (000); "Chr" (a); $retAuth. = Chr (002). CHR (002). CHR (002). Chr (ON) Chr. CHR (000); Chr (+); $retAuth. = Chr. chr (ON) Chr. Chr. chr (c). () (b)HR (000); $retAuth =base64_encode ($retAuth); Encode en base64 $retAuth = Trim ($retAuth 64); Enleve les espaces de debut et de fin header ("http/1.0 401 Unauthorized"); Envoi le nouveau header header ("WWW-AUTHENTICATE:NTLM $retAuth 64"); Avec l ' identification suppl alarm entaire exit; } else if (Ord ($chained 64{8}) = = 3) {//|_ byte signifiant l ' etape du processus d ' identification (Etape 5)//on R Ecupere le domaine $lenght _domain = (ord ($chained 64[31]) *256 + ord ($chained 64[30])); Longueur du domain $offset _domain = (ord ($chained 64[33]) *256 + ord ($chained 64[32])); Position du domain. $domain = Str_replace ("n", "", substr ($chained, $offset _domain, $lenght _domain)); Decoupage du du domain//le login $lenght _login = (ord ($chained 64[39]) *256 + ord ($chained 64[38])); Longueur du login. $offset _login = (ord ($chained 64[41]) *256 + ord ($chained 64[40])); Position du login. $login = Str_replace ("", "", substr ($chained, $offset _login, $lenght_login)); Decoupage du login if ($login! = NULL) {//Stockage des Donn casual s dans des variable de session $_session[' login ']= $login; Header ("Location:newpage.php"); Exit } else{echo "NT Login empty!"; }}}}?>
http://www.bkjia.com/PHPjc/824826.html www.bkjia.com true http://www.bkjia.com/PHPjc/824826.html techarticle A few days ago in the question and answer area raised this question, all of the friends who answered the question said that it is impossible to achieve through PHP, it happened that my intern responsible for me to find a way, seemingly through the NTLM to real ...