Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

NTLM - Not Telling Linux Much

by aufflick (Deacon)
on Feb 20, 2006 at 02:19 UTC ( #531332=perlquestion: print w/ replies, xml ) Need Help??
aufflick has asked for the wisdom of the Perl Monks concerning the following question:

I have tried in vain to do NTLM authentication via LWP. Well, via WWW::Mechanize, but that's just LWP underneath.

As in the message Re^2: More NTLM, I am suspecting Microsoft foul (and possibly fowl) play in augmenting the non-standard a little more.

I tried applying the suggested patch from http://rt.cpan.org/Public/Bug/Display.html?id=9521 but with the same result.

Is anyone currently having success with code connecting to IIS 5 NTLM authenticated pages?

NB: I am not connecting via a proxy and my code looks like this:

my $mech = WWW::Mechanize->new( keep_alive => 1, ); $mech->credentials( 'theserver.com:80', '', $username, $password );
I have also tried with and without specifying an NT domain.

Update: Here is my (sanitized) lwp debug output:

LWP::UserAgent::new: () LWP::UserAgent::proxy: ftp http://**url sanitized*** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 811 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 504 bytes LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUA**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 566 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 351 bytes LWP::Protocol::http::request: Keep the http connection to **url saniti +zed***:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In second phase of NTLM authenticatio +n LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABg**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 811 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 106 bytes LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUAA**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 566 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 351 bytes LWP::Protocol::http::request: Keep the http connection to **url saniti +zed***:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In second phase of NTLM authenticatio +n LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUAADAAAAGA**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 811 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1486 bytes LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVN**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized*** for cook +ies HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 566 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 351 bytes LWP::Protocol::http::request: Keep the http connection to **url saniti +zed***:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In second phase of NTLM authenticatio +n LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUA**chop** LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking **url sanitized***for cooki +es HTTP::Cookies::add_cookie_header: Checking .net for cookies LWP::UserAgent::send_request: GET http://**url sanitized*** LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 811 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 106 bytes LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication

Comment on NTLM - Not Telling Linux Much
Select or Download Code
Re: NTLM - Not Telling Linux Much
by crashtest (Curate) on Feb 20, 2006 at 22:47 UTC

    FWIW, I'm the guy who wrote Re^2: More NTLM. I hadn't looked at that code in ages; in fact, as soon as I got it working, I dropped the whole thing. Proof of concept, I suppose.

    I did just now run my simple test script and it still works. I am sorry I do not know the version of the IIS server I am running against.

    I am attaching my debug output at the bottom. One difference I noticed is that my initial response is short and sweet:

    LWP::Protocol::collect: read 24 bytes
    .. while your first response is not.
    LWP::Protocol::collect: read 566 bytes LWP::Protocol::collect: read 1736 bytes LWP::Protocol::collect: read 1380 bytes LWP::Protocol::collect: read 351 bytes
    Make of that what you may. Good luck!

    Full output:

      Interesting. I guess your IIS is returning much smaller tokens/seed/whatever. It may even be that it is a different algorithm and thus my response is not satisfying the requirement.

      Unfortunately I don't have access to the server but I will do some more investigation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://531332]
Approved by McDarren
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (16)
As of 2014-10-01 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls