Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Curl authentication problem

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
I'm using curl, my information line is... libcurl/7.10.5 OpenSSL/0.9.7b zlib/1.1.4

I'm trying to cURL into an ASP page which requires authentication... if I open the page in IE it doesn't say a word, if I open it in Firefox i get asked for username password.

The relevant headers returned from an HTTP request are
Code:
[URL unfurl="true"]WWW-Authenticate:[/URL] Negotiate
[URL unfurl="true"]WWW-Authenticate:[/URL] NTLM
[URL unfurl="true"]WWW-Authenticate:[/URL] Basic realm = "777.77.7.777"

I have a different commandline version of curl (7.10.4 I believe, but am not certain), if I run
Code:
curl -l -anyauth -u <domain>\<name>:<pwd> <website>

It returns the page just fine ... but this is on my development machine, not the webserver... I've tried

Code:
$ch = curl_init("[URL unfurl="true"]http://xxxx/xxx/xxxx.asp");[/URL]
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "<domain>\<name>:<pwd>");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_exec($ch);
curl_close($ch);

With no luck, 401 - Unauthorized: Logon Failed.... does anyone see anything I may be missing? Is there a specific curlopt I haven't set that I need to?
 
It is the proxy server most likely.
There is an Environment variable to set the proxy server.
 
There is a proxy server, I will dig into this, but if that's the problem, how is the command line version getting around it?
 
Yeah, that took it from a 401 to a 503 (unable to resolve hostname)... thanks for the idea though.
 
The command line version gets by because it gathers all the proxy info internally.

I had the same problem and thru debug got the err no which I found in the docs.

So now you have a DNS or port issue, which may be blocked thus preventing the hostname being resolved.

Try and add return codes to your functions, and see if you can find the specific error. The curl docs has a list which may help.
 
So I circumvented any DNS issues and fed it the IP address, and it goes right back to the Login not supported issue... which makes sense, because for an address of the type I'm sending it our proxy script returns DIRECT, in other words, it should skip the proxy.

Also in either case I was getting back error code 0.

So it's accessing the page just fine, it just won't pass the login.

But as I typed this, things just got stranger... I used another account and it worked... my first account still works fine from the command line but not through the script, what a whack job.
 
Ok, so it's going now, I won't even pretend to know what fixed it, I have a feeling the guy running the server changed something, sorry for the wild goose chase.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top