Prev: multi dimensional array question
Next: SharePoint
From: Robbert van Andel on 1 May 2010 02:58 I've been trying to connect to our SharePoint server's webservices with PHP. I downloaded the nusoap library and have been trying to make a connection using sample code from various websites. I keep getting the following error: <h1>You are not authorized to view this page</h1> You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept. <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.<br>Internet Information Services (IIS)</h2> My code looks like this: require_once('/usr/share/php/nusoap/nusoap.php'); /* Your username and password, separated by a colon Domain may be optional, depending on your setup */ $auth = "username:password"; /* Location of the Lists.asmx file If the list is in a subsite, the subsite must be in the path */ $wsdl = "http://domain.com/depts/is/private/_vti_bin/Lists.asmx?WSDL"; /* GUID of the list */ $guid = "Shared Documents"; /* Setup NuSOAP Sharepoint requires NTLM Authorization You need a fairly recent version of CURL installed for this */ try { $client = new nusoap_client($wsdl,true); $client->setCredentials("","","ntlm"); $client->setUseCurl(true); $client->useHTTPPersistentConnection(); $client->setCurlOption(CURLOPT_USERPWD, $auth); //$client->soap_defencoding = 'UTF-8'; $xml = ' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $guid . '</listName> <viewName>All Documents</viewName> <query> <xsd:schema>schema</xsd:schema>xml</query> <viewFields> <xsd:schema>schema</xsd:schema>xml</viewFields> <rowLimit>string</rowLimit> <queryOptions> <xsd:schema>schema</xsd:schema>xml</queryOptions> <webID>string</webID> </GetListItems> </soap:Body> </soap:Envelope> '; $result = $client->call("GetListItems",$xml); if(isset($fault)) { echo "<p>Error: " . $fault . "</p>\n"; } echo "<pre>\$result = " . htmlspecialchars(print_r($result,true)) . "</pre>\n"; } catch(Exception $e) { echo "<p>" . $e->getMessage() . "</p>\n"; } Our SharePoint server uses integrated authentication. I've tried several permutations of the username, including just the username, domain\username and username(a)domain. All are returning the same error. My guess is that PHP is sending the username/password combination in a way that SharePoint doesn't like. Has anyone been able to connect to SharePoint's web services and if so, how? Thanks
From: "Tommy Pham" on 1 May 2010 11:32 > -----Original Message----- > From: Robbert van Andel [mailto:swimmer1974(a)gmail.com] > Sent: Friday, April 30, 2010 11:58 PM > To: PHP list - not junk > Subject: [PHP] SharePoint > > I've been trying to connect to our SharePoint server's webservices with PHP. > I downloaded the nusoap library and have been trying to make a connection > using sample code from various websites. I keep getting the following error: > > <h1>You are not authorized to view this page</h1> You do not have > permission to view this directory or page using the credentials that you > supplied because your Web browser is sending a WWW-Authenticate header > field that the Web server is not configured to accept. > <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server > configuration.<br>Internet Information Services (IIS)</h2> > .... > > Our SharePoint server uses integrated authentication. I've tried several > permutations of the username, including just the username, > domain\username and username(a)domain. All are returning the same error. > My guess is that PHP is sending the username/password combination in a > way that SharePoint doesn't like. > > Has anyone been able to connect to SharePoint's web services and if so, > how? > > Thanks > Hi, Is the SharePoint web app security configured as NTLM or Kerberos? I presume the authentication type is Windows? Have you tried http://user:password(a)domain.com/full/path/of/url?qryParam=value? Regards, Tommy
From: Richard Quadling on 1 May 2010 15:27 On 1 May 2010 07:59, Robbert van Andel <robbert(a)vafam.com> wrote: > I've been trying to connect to our SharePoint server's webservices > with PHP. I downloaded the nusoap library and have been trying to make > a connection using sample code from various websites. I keep getting > the following error: > > <h1>You are not authorized to view this page</h1> > You do not have permission to view this directory or page using the > credentials that you supplied because your Web browser is sending a > WWW-Authenticate header field that the Web server is not configured to > accept. > <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server > configuration.<br>Internet Information Services (IIS)</h2> > > My code looks like this: > > require_once('/usr/share/php/nusoap/nusoap.php'); > > /*  Your username and password, separated by a colon >   Domain may be optional, depending on your setup */ > $auth = "username:password"; > > /*  Location of the Lists.asmx file >   If the list is in a subsite, the subsite must be in the path */ > $wsdl = "http://domain.com/depts/is/private/_vti_bin/Lists.asmx?WSDL"; > > /*  GUID of the list */ > $guid = "Shared Documents"; > > /* Setup NuSOAP >  Sharepoint requires NTLM Authorization >  You need a fairly recent version of CURL installed for this  */ > try { >     $client = new nusoap_client($wsdl,true); >     $client->setCredentials("","","ntlm"); >     $client->setUseCurl(true); >     $client->useHTTPPersistentConnection(); >     $client->setCurlOption(CURLOPT_USERPWD, $auth); >     //$client->soap_defencoding = 'UTF-8'; > > >     $xml = ' > <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> >  <soap:Body> >   <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> >    <listName>' . $guid . '</listName> >    <viewName>All Documents</viewName> >    <query> >     <xsd:schema>schema</xsd:schema>xml</query> >    <viewFields> >     <xsd:schema>schema</xsd:schema>xml</viewFields> >    <rowLimit>string</rowLimit> >    <queryOptions> >     <xsd:schema>schema</xsd:schema>xml</queryOptions> >    <webID>string</webID> >   </GetListItems> >  </soap:Body> > </soap:Envelope> >     '; > >     $result = $client->call("GetListItems",$xml); >     if(isset($fault)) { >         echo "<p>Error: " .. $fault . "</p>\n"; >     } >     echo "<pre>\$result = " . > htmlspecialchars(print_r($result,true)) . "</pre>\n"; >  } > catch(Exception $e) { > >     echo "<p>" . $e->getMessage() . "</p>\n"; > } > > > Our SharePoint server uses integrated authentication. I've tried > several permutations of the username, including just the username, > domain\username and username(a)domain. All are returning the same error. > My guess is that PHP is sending the username/password combination in a > way that SharePoint doesn't like. > > Has anyone been able to connect to SharePoint's web services and if so, how? > > Thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I've not tried cURL, but I have managed to get PHP to talk through an NTLM proxy. See my user note on http://docs.php.net/manual/en/function.stream-context-get-default.php Unfortunately, the link to an old site I had is dead. But it was just some long windedness about http://ntlmaps.sourceforge.net/ Though you can use the Way Back When Machine (please make sure your ad blockers are working - sorry!!!!) : http://web.archive.org/web/20080427012158/http://rquadling.php1h.com/php_ntlm.php If you go down this route, then also take a look at http://web.archive.org/web/20080501043118/rquadling.php1h.com/python_ntlm.php which is more on the same. What this all means that you use the NTLMAPS proxy to do the NTLM authentication for you. But, hopefully, all of this isn't needed and that PHP now supports NTLM authentication within cURL. Ideally, it should also be available for regular stream contexts. Richard. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
|
Pages: 1 Prev: multi dimensional array question Next: SharePoint |