Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby/Rails and Sharepoint Web Services

I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attempting to use an actual web service call.

Has anyone had any experience getting ruby and Sharepoint to talk?

like image 387
Kevin Colyar Avatar asked Dec 16 '08 19:12

Kevin Colyar


3 Answers

I'm a total newb. But after a lot of time and with some help from more experience coders, I was able to get ruby working with Sharepoint 2010. The code below requires the 'ntlm/mechanize' gem.

I've been able to download the sharepoint xml from lists specified (below) using the List GUID and the List View GUID.

Edit (May 23, 2011). I should have pointed out that this code requires the ruby-ntlm gem. Here's a decent link that should help. This definitely works.

http://rubydoc.info/gems/ruby-ntlm/0.0.1/file/README.markdown

agent = Mechanize.new
agent.auth('domain\\USERNAME', 'PASSWORD')
page = agent.get('http://URL/DIRECTORY/SITE/LIST/_vti_bin/owssvr.dll?Cmd=Display&List={LIST_GUID}&View={VIEW_GUID}&XMLDATA=TRUE')
like image 131
Bob Avatar answered Nov 15 '22 19:11

Bob


How did you change the SP server to use Basic Auth? Did you just configure the site via IIS, or did you do it through SP Central Admin?

If you're using SP 2007/MOSS, you need to change it via Central Admin; if 2003, you need to do it via IIS.

What error do you get when the request fails?

like image 26
Greg Hurlman Avatar answered Nov 15 '22 18:11

Greg Hurlman


NTLM is not supported by soap4r somehow, eventhough httpclient does support it.

When enabling basic auth is not an option, you could consider using kerberos i.e. negotiate auth method. Enabling this in sharepoint is a bit tricky, but basically comes down to doing the following on the commandline of the server:

cscript adsutil.vbs set w3svc/1/NTAuthenticationProviders "Negotiate,NTLM"

It might have some wird concequences it seems, check this forum post for more info. Finally you need to set the authentication in soap4r with auth= instead of basic_auth= i think.

like image 45
Arthur Avatar answered Nov 15 '22 19:11

Arthur