2017-12-20 27 views
0

누구든지 PHP libcurl (PHP 5.6.4가 libcurl v7.39.0 인 Windows에서 실행 중)과 cURL 7.57.0에서 --negotiate 사이의 CURLAUTH_NEGOTIATE 사이에서 다른 점을 밝힐 수 있습니까? 명령 줄을 통해 컬 7.57.0을 사용PHP libcurl에서 CURLAUTH_NEGOTIATE의 차이점 VS. --negotiate in cURL 7.57.0

다음 요청은 작동합니다

curl --negotiate -u MYDOMAIN\myuser:mypass http://myip:myport/mywebservice.svc 

내가 libcurl에서의 v7.39.0와 PHP 5.6.4 (Windows에서 실행)를 사용하여 아래의 코드를하려고하면

0,123,516 : 여기
<?php 
//Set vars 
$url = "http://myip:myport/mywebservice.svc"; // asmx URL of WSDL 
$un = "myuser"; // username 
$password = "mypass"; // password 
$domain = "MYDOMAIN\\"; // domain 

//Create, Send and Output cURL Request 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE); 
curl_setopt($ch, CURLOPT_USERPWD, $domain . $un.":".$password); 

$response = curl_exec($ch); 
echo $response; 
?> 

는 PHP CURL 설정은 다음과 같습니다 원격 웹 서버는 401.2 오류를 반환
cURL support => enabled 
cURL Information => 7.39.0 
Age => 3 
**Features** 
AsynchDNS => Yes 
CharConv => No 
Debug => No 
GSS-Negotiate => No 
IDN => Yes 
IPv6 => Yes 
krb4 => No 
Largefile => Yes 
libz => Yes 
NTLM => Yes 
NTLMWB => No 
SPNEGO => Yes 
SSL => Yes 
SSPI => Yes 
TLS-SRP => No 
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp 
Host => i386-pc-win32 
SSL Version OpenSSL/1.0.1i 
ZLib Version => 1.2.7.3 
libSSH Version => libssh2/1.4.3 

어떤 통찰력이라도 대단히 감사합니다! 감사합니다 ~ Dan

답변

0

위의 문제를 해결하려면 PHP에서 사용하는 libcurl을 우회하고 있습니다. 나는 최신 버전의 cURL을 https://curl.haxx.se/download.html (우리 서버는 Windows에, 단지 FYI)에서 다운로드하여 액세스 가능한 디렉토리에 넣습니다. 마법처럼

<?php 

//Set vars 
$url = "http://<my_host_ip_or_domain>:<my_host_post_if_needed>/<my_path_etc>"; 
$userName = "DOMAIN\username"; 
$password = "password"; 
$filePath = "myxmlfile.xml"; 
$contentLength = strlen(file_get_contents($filePath)); 

//Set any curl args (other than headers) you wish - per https://curl.haxx.se/docs/manpage.html (These are the ones I needed to solve my particular authentication problem) 
$curlSettings = array(); 
$curlSettings["--negotiate"] = ''; 
$curlSettings["-u"] = $userName .':'. $password; 
$curlSettings["--http1.1"] = ''; 
$curlSettings["--location-trusted"] = ''; 
$curlSettings["--post301"] = ''; 
$curlSettings["--data"] = '@"'. $filePath .'"'; 


//Set any cURL headers you want 
$curlHeaders = array(
    'Content-Type: text/xml; charset=utf-8', 
    'Content-Length: '. $contentLength, 
    'SOAPAction: http://tempuri.org/blahblahblah', 
    'Host: <my_host_ip>:<my_host_port>' 
); 

//Call the function 
$curlResp = curlRequest($url, $curlSettings, $curlHeaders); 

//Output the result 
echo '<pre>'; 
print_r($curlResp); 
echo '</pre>'; 


//Handle cURL Request 
function curlRequest($url,$args,$headers) 
{ 
    /* 
     Note: This needs to be the full path to CURL on server or you can set it to run as a windows cmd (as I have), 
     by following the instructions outlined by Michiel van Oosterhout in the following post: 
     https://stackoverflow.com/questions/9507353/how-do-i-install-set-up-and-use-curl-on-windows 
    */ 
    $strCurl = "curl"; 

    //Add Args/Setting to cURL request 
    foreach ($args as $key => $val) 
    { 
     $strCurl .= " ". $key ." ". $val; 
    } 

    //Add headers to cURL request 
    foreach ($headers as $h) 
    { 
     $strCurl .= ' --header "'. $h .'"'; 
    } 

    //Set the URL 
    $strCurl .= " ". $url; 

    //Execute the curl request 
    exec($strCurl, $resp); 

    //Return an array of the response 
    return $resp; 
} 

?> 

작품 :

그런 다음 단순히 다음과 같은 코드를 작성!