NTLM authentication against a Sharepoint Server

Discussion in 'Perl Misc' started by Laurence, Jul 7, 2005.

  1. Laurence

    Laurence Guest

    Hey guys,

    I've been trying without success to have a perl script authenticate
    against our Sharepoint Portal Server using NTLM.

    Here's what I have:

    #!/usr/bin/perl

    use LWP::UserAgent;
    use HTTP::Request;
    use MIME::Base64;
    use LWP::Debug qw(+);

    sub getItemsFromSharepoint {
    # use GetListItems webservice on sharepoint

    my $url = 'http://portal01/';
    my $ua = new LWP::UserAgent(keep_alive=>1);
    $ua->credentials('portal01:80','',"domain\\username", 'password');

    $request = HTTP::Request->new(GET=>$url);
    print "--Performing request now...-----------\n";
    $response = $ua->request($request);
    print "--Done with request-------------------\n"; if
    ($response->is_success) {print "It worked!->" . $response->code . "\n"}
    else {print "It didn't work!->" . $response->code . " " .
    $response->content . "\n"}

    }

    LWP::UserAgent::new: ()
    --Performing request now...-----------
    LWP::UserAgent::request: ()
    LWP::UserAgent::send_request: GET http://portal01/
    LWP::UserAgent::_need_proxy: Not proxied
    LWP::protocol::http::request: ()
    LWP::protocol::collect: read 792 bytes
    LWP::protocol::collect: read 864 bytes
    LWP::protocol::http::request: Keep the http connection to portal01:80
    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
    header:
    Authorization NTLM TlRM<REMOVE>
    LWP::UserAgent::request: ()
    LWP::UserAgent::send_request: GET http://portal01/
    LWP::UserAgent::_need_proxy: Not proxied
    LWP::protocol::http::request: ()
    LWP::protocol::collect: read 607 bytes
    LWP::protocol::collect: read 302 bytes
    LWP::protocol::collect: read 630 bytes
    LWP::protocol::http::request: Keep the http connection to portal01:80
    LWP::UserAgent::request: Simple response: Unauthorized
    LWP::Authen::Ntlm::authenticate: authenticate() has been called
    LWP::Authen::Ntlm::authenticate: In second phase of NTLM authentication
    LWP::Authen::Ntlm::authenticate: Returning response object with auth
    header:
    Authorization NTLM TlRMTVN<REMOVED>

    Now, I've removed the encoded NTLM just for security sake... I've
    compared it to the encoding generated by Mozilla when accessing the
    same page and they are no where near alike... Any ideas why they are so
    different? Anything that you guys can see wrong? It loops through this
    three times and then fails.

    Thanks,
    Laurence
    Laurence, Jul 7, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlos Fersura

    WebControls and NTLM Authentication

    Carlos Fersura, Nov 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    340
    Carlos Fersura
    Nov 3, 2003
  2. Buddy Ackerman
    Replies:
    2
    Views:
    472
  3. Will
    Replies:
    5
    Views:
    2,611
  4. frikk

    Python, Sharepoint, .NET, NTLM

    frikk, Aug 15, 2007, in forum: Python
    Replies:
    1
    Views:
    1,679
  5. Matthijs
    Replies:
    0
    Views:
    834
    Matthijs
    Dec 10, 2008
Loading...

Share This Page