IdentAuth.class.php (1238B)
1 <?php 2 3 /** 4 * Authentifizierung via Ident-Server. 5 * 6 * Der Benutzername wird über einen Ident-Server, der auf dem 7 * Client installiert sein muss, ermittelt. 8 * 9 * @author dankert 10 */ 11 class IdentAuth implements Auth 12 { 13 public function username() 14 { 15 $ip = Http::getClientIP(); 16 $port = Http::getClientPort(); 17 $identPort = 113; 18 if ( !$socket = @fsockopen($ip,$identPort,$errno, $errstr,10 )) 19 { 20 return null; 21 } 22 23 $line = $port.','.$_SERVER['SERVER_PORT']."\r\n"; 24 @fwrite($socket, $line); 25 $line = @fgets($socket, 1000); // 1000 octets according to RFC 1413 26 fclose($socket); 27 28 $array = explode(':', $line, 4); 29 if (count($array) >= 4 && ! strcasecmp(trim($array[1]), 'USERID')) 30 { 31 $username = trim($array[3]); 32 Logger::debug('Ident: User-Id: '.$username ); 33 return $username; 34 } 35 elseif (count($array) >= 3 && ! strcasecmp(trim($array[1]), 'ERROR')) 36 { 37 Logger::debug('Ident: Error: '.trim($array[2]) ); 38 return null; 39 } 40 else 41 { 42 Logger::warn('Ident: Invalid ident server response: '.$line); 43 return null; 44 } 45 } 46 47 48 /** 49 * Ueberpruefen des Kennwortes ist über Ident nicht möglich. 50 */ 51 public function login( $user, $password, $token ) 52 { 53 return OR_AUTH_STATUS_FAILED; 54 } 55 } 56 57 ?>