Bonjour a tous , j'ai un problème qui me coince depuis un bout de temps, je m'explique

j'ai une fonction qui me permet de récupérer le login AD de l'utilisateur qui visite la page ( get_login() )

elle marche parfaitement en me retournant le le bon nom de l'user, mais quand je fait une requête sql pour verifier si il est dans ma BDD, il ne me trouve aucun résultats ! alors que les donnée son bien dans la BDD

Si je fait la requête dans phpmyadmin ou directement dans mysql, elle me renvoie bien la bonne valeur

si vous avez une idée sa m'aiderait bcp, marci d'avance.



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
 Utilisation de la fonction
 
include "connect.inc";
include "config.inc";
include "functions.inc";
 
 
 
$login = get_login(); 
 
echo gettype($login);
$popo = $login;
 
 
 
 
 
echo "<br> ";
 
 
 
 
$sql = "select COUNT(*) aaa from `utilisateurs` where `login`='$popo';";
 
$A =  mysql_query($sql); 
 
$row=mysql_fetch_object($A);
 
echo "La table comporte ".$row->aaa." enregistrement(s) <br>";  
echo $sql;







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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 Fonction pour récupérer le login 
Function get_login()
{
 
	//#################################################################################
	/***********************************************************************
	*   PHP NTLM GET LOGIN  
	*   Version 0.2
	* ====================================================    
	*                                        
	* Copyright (c) 2004 Nicolas GOLLET (Nicolas.gollet@secusquad.com)
	* Copyright (c) 2004 Flextronics Saint-Etienne
	*
	* This program is free software. You can redistribute it and/or modify  
	* it under the terms of the GNU General Public License as published by  
	* the Free Software Foundation; either version 2 of the License.        
	*
	***********************************************************************/
 
 
	/*
	L'identification par NTLM se fait en 6 étape :
 
	étape: | type:   | Info échangé
	-------|----------------|--------------------------------------------------
	    1  | C  --> S   | GET ...        legende : C = Client
	-------|----------------|--------------------------------------------------         S = Serveur
	    2  | C <--  S  | 401 Unauthorized
	       |            | WWW-Authenticate: NTLM
	-------|----------------|--------------------------------------------------
	    3  | C  --> S   | GET ...
	       |           | Authorization: NTLM <base64-encoded type-1-message>
	-------|----------------|--------------------------------------------------
	    4  | C <--  S  | 401 Unauthorized
	       |           | WWW-Authenticate: NTLM <base64-encoded type-2-message>
	-------|----------------|--------------------------------------------------
	    5  | C  --> S   | GET ...
	       |                | Authorization: NTLM <base64-encoded type-3-message>
	-------|----------------|--------------------------------------------------    
	    6  | C <--  S       | 200 Ok
	-------|----------------|--------------------------------------------------
 
	*/
 
 
 
	$headers = apache_request_headers();  // Récupération des l'entêtes client
 
 
	if($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 :
	  if (ord($chained64[13]) != 178){
	  echo "Votre navigateur Internet n'est pas compatible avec le NTLM, utiliser IE...Merci";
	  exit;
	  }
	   $retAuth = "NTLMSSP";      
	   $retAuth .= chr(0);      
	   $retAuth .= chr(2);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(40);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(1);
	   $retAuth .= chr(130);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(2);
	   $retAuth .= chr(2);
	   $retAuth .= chr(2);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
	   $retAuth .= chr(0);
 
	   $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 = 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 = substr($chained64, $offset_login, $lenght_login); // decoupage du login
 
	  // l'host  
	  $lenght_host = (ord($chained64[47])*256 + ord($chained64[46])); // longueur de l'host.
	  $offset_host = (ord($chained64[49])*256 + ord($chained64[48])); // position de l'host.  
	  $host = substr($chained64, $offset_host, $lenght_host); // decoupage du l'host  
	 }
 
	 }
 
	}
	  //#####################################################################################
 
 
 
 
 
$login = strtolower($login);
 
	return $login;
}
 
 
 
?>