Bonjour, j'essais depuis pas mal de temps de récupérer le nom de session windows de l'utilisateur afin d'éviter une énième authentification. J'ai trouvé un bout de code qui est censé faire ça sur le net mais j'obtiens les erreurs suivantes :

Notice: Undefined index: Authorization in c:\changepwdcontrol.php on line 8

Warning: Cannot modify header information - headers already sent by (output started at c:\changepwdcontrol.php:3) in c:\changepwdcontrol.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at c:\changepwdcontrol.php:3) in c:\changepwdcontrol.php on line 10
Pourtant, concernant les erreurs sur les headers, je n'ai aucun code html devant ni après les balises php...

Quelqu'un à t'il une idée ?

voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
 
<?php
$headers = apache_request_headers(); 	// Récupération des l'entêtes client
 
if (@$_SERVER['HTTP_VIA'] != NULL){ // nous verifions si un proxy est utilisé : parceque l'identification par ntlm ne peut pas passer par un proxy
	echo "Proxy bypass!";
}
elseif($headers['Authorization'] == NULL){				//si l'entete autorisation est inexistante
		header( "HTTP/1.0 401 Unauthorized" );			//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($headers['Authorization'],0,5) == 'NTLM '){ 	// on vérifit que le client soit en NTLM
 
			$chaine=$headers['Authorization']; 					
			$chaine=substr($chaine, 5); 			// recuperation du base64-encoded type1 message
			$chained64=base64_decode($chaine);		// decodage base64 dans $chained64
 
			if(ord($chained64{8}) == 1){					
			// 		  |_ byte signifiant l'etape du processus d'identification (etape 3)		
 
			// verification du drapeau NTLM "0xb2" à l'offset 13 dans le message type-1-message (comp ie 5.5+) :
				if (ord($chained64[13]) != 178){
					echo "NTLM Flag error!";
					exit;
				}
 
				$retAuth = "NTLMSSP".chr(000).chr(002).chr(000).chr(000).chr(000).chr(000).chr(000).chr(000);
				$retAuth .= chr(000).chr(040).chr(000).chr(000).chr(000).chr(001).chr(130).chr(000).chr(000);
				$retAuth .= chr(000).chr(002).chr(002).chr(002).chr(000).chr(000).chr(000).chr(000).chr(000);
				$retAuth .= chr(000).chr(000).chr(000).chr(000).chr(000).chr(000).chr(000);
 
				$retAuth64 =base64_encode($retAuth);		// encode en base64
				$retAuth64 = trim($retAuth64); 			// enleve les espaces de debut et de fin
				header( "HTTP/1.0 401 Unauthorized" ); 		// envoi le nouveau header
				header( "WWW-Authenticate: NTLM $retAuth64" );	// avec l'identification supplémentaire
				exit;
 
			}
 
			else if(ord($chained64{8}) == 3){
			// 		       |_ byte signifiant l'etape du processus d'identification (etape 5)
 
				// on recupere le domaine
				$lenght_domain = (ord($chained64[31])*256 + ord($chained64[30])); // longueur du domain
				$offset_domain = (ord($chained64[33])*256 + ord($chained64[32])); // position du domain.	
				$domain = str_replace("\0","",substr($chained64, $offset_domain, $lenght_domain)); // decoupage du du domain
 
				//le login
				$lenght_login = (ord($chained64[39])*256 + ord($chained64[38])); // longueur du login.
				$offset_login = (ord($chained64[41])*256 + ord($chained64[40])); // position du login.
				$login = str_replace("\0","",substr($chained64, $offset_login, $lenght_login)); // decoupage du login
 
				if ( $login != NULL){
					// stockage des données dans des variable de session
					$_SESSION['Login']=$login;
					header("Location: newpage.php");
					exit;
				}
				else{
					echo "NT Login empty!";
				}
 
 
			}
		}
 
}
 
 
?>
Le probleme pour l'instant porte seulement sur le début du code