Loading ...
Sorry, an error occurred while loading the content.

Need example authenticating to Microsoft Sharepoint

Expand Messages
  • anagramster
    Anyone have a sample script that shows how to access the web services of Microsoft Sharepoint (or something similar)? I seem to be hung up on the
    Message 1 of 1 , Apr 26, 2004
    • 0 Attachment
      Anyone have a sample script that shows how to access the web services
      of Microsoft Sharepoint (or something similar)?

      I seem to be hung up on the authentication, which appears to be NTLM,
      and requires keep-alive.

      Here's some test code that fails (output follows):

      ------------------------------------------
      #!perl -w

      $| = 1; # no output buffering

      use lib '/cygdrive/v/download/Perl/SOAP-Lite-0.60/blib/lib';

      use strict;
      use SOAP::Lite 0.60 trace => 'debug';
      use Authen::NTLM;

      # from http://cpan.uwinnipeg.ca/htdocs/SOAP-Lite/SOAP/Lite.html
      $SOAP::Constants::PATCH_HTTP_KEEPALIVE = 1;
      # this is only for the developmet release (v0.60)

      my $host = 'http://sharepoint.host.url/';

      my $wsdlPath = 'WSDL/Webs.wsdl';
      my $request = SOAP::Lite->service( "file:$wsdlPath" );

      print "here!\n";

      my $response = $request->GetWeb( $host );
      foreach my $result (@{$response->{'GetWebResult'}}) {
      print $result, "\n";
      }

      sub SOAP::Transport::HTTP::Client::get_basic_credentials {
      print "kicked!\n";
      return 'user' => 'password';
      }
      ------------------------------------------------


      bash-2.05b$ perl test.pl

      SOAP::Transport::HTTP::Client::send_receive: POST
      http://sharepoint.host.url/_vti_bin/Webs.asmx HTTP/1.1
      Accept: text/xml
      Accept: multipart/*
      Content-Length: 468
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetWeb"

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-
      ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
      ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-
      ENV:Body><GetWeb xmlns=""><parameters>foo</parameters></GetWeb></SOAP-
      ENV:Body></SOAP-ENV:Envelope>

      kicked!

      The keep_alive option must be enabled for NTLM authentication to
      work. NTLM authentication aborted.

      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 401 Unauthorized
      Date: Thu, 01 Apr 2004 01:01:08 GMT
      Server: Microsoft-IIS/6.0
      WWW-Authenticate: NTLM
      Content-Length: 1656
      Content-Type: text/html
      Content-Type: text/html; charset=Windows-1252
      Client-Date: Thu, 01 Apr 2004 01:01:09 GMT
      Client-Peer: 134.120.102.156:80
      Client-Response-Num: 1
      MicrosoftSharePointTeamServices: 6.0.2.5530
      Title: You are not authorized to view this page
      X-Powered-By: ASP.NET
    Your message has been successfully submitted and would be delivered to recipients shortly.