AnsweredAssumed Answered

Kerberos Authentification in PHP

Question asked by eat_k on Dec 14, 2016
Latest reply on Dec 15, 2016 by eat_k



Currently, we have a server with PI Web API and I would like to write a php script to retrieve values from it. Our server supports Kerberos authentification as we have a LDAP Server managing user accesses. For starters, I used the following references :

- PI Web API and Kerberos Authentication via PHP

- Developping with PI Web API

-Developing a PHP application using PI Web API

- Php Manual for Kerberos Library


And the main lines of code I put together so far (comes from the first link) :

$username = 'domain\\username'; //for testing purpore, not staying here in the final version
$password = 'password';         //for testing purpose, not staying here in the final version
$url = 'https://mypiserver/piwebapi';

$ch = curl_init ( $url );  
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );

curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
$result = curl_exec ( $ch );


However, I get a HTTP 401 header in the response, as the authentification failed. I tried the other solutions above, but no success so far, and I can't seem to figure out exactly where the problem comes from. I suspect the credentials to be wrongly formatted but I have no clues about how to ensure it is the correct way.  Am I doing something wrong ?


Thank you.