in reply to LWP::UserAgent Authentication

Hi Palladinob, welcome to Perlmonks!

CPAN module LWP::Authen::Ntlm should be able to help you, as it has been designed to deal with Ntlm type of authentication. You probably have it installed with LWP already.

So in your code there is no need to add the subroutine, just use the credentials method, e.g.:

use LWP; my $ua = new LWP::UserAgent(keep_alive=>1); $ua->credentials('www.company.com:80', '', "MyDomain\\MyUsername", 'M +yPassword');

To improve the readability of your question pls see Writeup formatting Tips

Replies are listed 'Best First'.
Re^2: LWP::UserAgent Authentication
by palladinob (Novice) on Mar 20, 2007 at 17:21 UTC
    Tried that. That one's right out of the LWP::Authen::NTLM module write-up. Didn't work.
      Alternatively try to access the page with a regular browser. If it pops up with a 'standard' username/password box then make a note of the realm and insert that into your credentials method as the second argument. You may be dealing with a server that requires regular digest authentication.
      Popup will have something like this:
      Enter username and password for "realmname_here" at http://...
      Update: btw make sure to append the portnumber (:80) to your fully qualified hostname in argument one, otherwise authentication can fail even with correct credentials.
        I tried all different strings for the realm. None of them worked. It doesn't specify the realm when it asks for the password. The word 'realm' doesn't even appear in a Sniffer trace. That's why I expected my sample code to work - it by-passes the credentials/realm problem and returns with the correct username/password. I also made sure I included the port number - 80. That was spelled out on one of the web sites: www.tutorials-blog.com/perl/LWPUserAgent-credentials/.
          A reply falls below the community's threshold of quality. You may see it by logging in.