我试图将php-curl与微软网络服务一起使用:这是我的代码(在带有wamp的Windows 10上工作):
<?php
$location = "http://10.0.100.19:7058/FOLDER12013/OData/Company('TEST')/WS_Clienti";
$handle = curl_init($location);
$credentials = 'CPGNET\username:password';
$action =
$proxy = '11.22.33.44:8123';
$headers = [
'Method: GET',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
];
// Authentication
curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM | CURLAUTH_BASIC | CURLAUTH_GSSNEGOTIATE | CURLAUTH_ANY);
curl_setopt($handle, CURLOPT_USERPWD, $credentials);
curl_setopt($handle, CURLINFO_HEADER_OUT, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($handle, CURLOPT_PROXY,$proxy);
$response = "";
echo("<pre>");
$response = curl_exec($handle);
$url_info = curl_getinfo($handle);
print_r($url_info);
echo(htmlentities($response));
echo("</pre>");
当我尝试从centos 7(或ubuntu 15)使用此代码时,我有一个错误401 unautorized。 Php,curl,libcurl在Windows和Linux上具有相同的版本(并且所有扩展都与phpinfo相同)。所以,我试图使用linux中的curl:
curl --negotiate -u "CPGNET\username:password" --proxy 11.22.33.44:8123 "http://10.0.100.19:7058/FOLDER12013/OData/Company('TEST')/WS_Clienti" -v
但我有一个错误:
* gss_init_sec_context() failed: : SPNEGO cannot find mechanisms to negotiate
请有人可以帮助我。我不明白为什么从linux这不起作用。 谢谢
答案 0 :(得分:0)
一个老问题,但是...
可能是您通过curl的gssapi遇到了ntlm身份验证的问题。请查看以下链接: