L
Laurence
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:ebug 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:rotocol::http::request: ()
LWP:rotocol::collect: read 792 bytes
LWP:rotocol::collect: read 864 bytes
LWP:rotocol::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:rotocol::http::request: ()
LWP:rotocol::collect: read 607 bytes
LWP:rotocol::collect: read 302 bytes
LWP:rotocol::collect: read 630 bytes
LWP:rotocol::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
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:ebug 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:rotocol::http::request: ()
LWP:rotocol::collect: read 792 bytes
LWP:rotocol::collect: read 864 bytes
LWP:rotocol::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:rotocol::http::request: ()
LWP:rotocol::collect: read 607 bytes
LWP:rotocol::collect: read 302 bytes
LWP:rotocol::collect: read 630 bytes
LWP:rotocol::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