2013-04-11 45 views
0

我正在ejabberd中实施外部身份验证。我正在使用一个PHP的MySQL脚本,它是provided by ejabberd。不幸的是,当我尝试连接存储在表中的用户详细信息时,它给我一个错误。通过ejabberd发出的外部身份验证错误

=ERROR REPORT==== 2013-04-11 13:17:54 === 
E(<0.269.0>:extauth:133) : extauth call '["auth","admin","localhost","admin"]' didn't receive 
response 

=INFO REPORT==== 2013-04-11 13:17:54 === 
I(<0.462.0>:ejabberd_c2s:649) : 
({socket_state,ejabberd_http_bind,{http_bind,<0.461.0>,{{127,0,0,1},39426}},ejabberd_http_bind}) 
Failed authentication for [email protected] 

有人能帮助我吗?

+1

'管理员@本地主机验证失败请确保用户管理员可以从本地主机连接。 – hek2mgl 2013-04-11 10:44:51

+0

在这我使用strophe js作为jabber客户端。我想通过MySQL的PHP​​实现外部认证,但它没有连接。如果我使用内部认证,那么它工作正常。 – Rajan 2013-04-11 13:25:38

回答

0

错误表示您在60秒内未收到来自外部程序的响应(即默认超时)。

您是否在ejabberd.cfg的extauth_program中定义了它?

0

花了1天试图获得工作ejabberd授权。
问题基本上出现在从标准输入读取时阻止进程。
这里是用于非块符号由符号从描述符读取的溶液:

function non_block_read($fd, &$data) { 
    $read = array($fd); 
    $write = array(); 
    $except = array(); 
    $result = stream_select($read, $write, $except, 0); 
    if($result === false) { 
       throw new Exception('stream_select failed'); 
     } 
    if($result === 0) return false; 
    $data.= stream_get_line($fd, 1); 
    return true; 
} 

这里是守护程序代码也使寿命读取周期。

$fh = fopen("php://stdin", 'r'); 
$fhout = fopen("php://stdout", 'w'); 
$pdo = new PDO('mysql:host='.$host.';dbname='.$db, $user,$pass); 
if(!$fh){ 
    die("Cannot open STDIN\n"); 
} 
$aStr=''; 
$collect=false; 
do { 
     if (!non_block_read($fh,$aStr)) { 
       if (strlen($aStr) > 0) { 
         $toAuth = substr(trim($aStr),1); 
         checkAuth($toAuth,$pdo,$fhout); 
         $aStr=''; 
       } 
       else sleep (1); 
     } 
} 
while (true); 

一些解释:checkAuth - 实现'auth'和'isuser'处理程序的任何函数。
睡眠(1) - 简单的方法来逃避CPU负载。
第一个符号 - 前置消息的服务符号,它不同于客户端,因此我只是将其剪下。
这里是答复代码。回复 - true |错误的值。

$message = @pack("nn", 2, $result); 
fwrite($stdout, $message); 
flush(); 

享受。