Link to home
Start Free TrialLog in
Avatar of canuckconsulting
canuckconsultingFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Connect to Sharepoint server using .Net C#

We have a corporate Sharepoint 2007 server which I would like to connect to using .Net.  My domain is recognised and I am open the following Excel spreadsheet using the following path:

http://coll.isite.mycompany.net/corp/it/Documents/SD%20Metrics.xlsx

I am using Visual Studio 2010 Pro and need to process this Excel from a Windows Forms c# application.  I will need to specify credentials as this may be run from an account without sufficient permissions.
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Well, I wrote this a while back to supply credentials and return a file from SP;

http://the-north.com/sharepoint/post/2008/02/10/Accessing-Sharepoint-Documents-from-Winforms-via-HTTPS.aspx

Would your requirements extend beyond this?
ASKER CERTIFIED SOLUTION
Avatar of Jamie McAllister
Jamie McAllister
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of canuckconsulting

ASKER

This looks great!

I am receiving the error "The remote server returned an error: (401) Unauthorized.".  What format do you use to submit credentials?  I used "EMEA\my.name".  Is this correct?

Also what does the "@" symbol indicate?
The @ is allowing you to put slashes and backslashes into the string.

MyDomain\UserID should be fine.
@...very handy!

If I log in as myself with my account and set UseDefaultCredentials to true I can connect but if I set it to false and try again I continue to get the unauthorized error."  Any thoughts?

Also have you been able to use this system to create a new document in sharepoint and/or update an existing one?
Is there a dot in the username? Do you normally login with that ID?

I wouldn't use this to create a document. I'd probably call the lists.asmx web services for that or use Client Object Model.

http://www.sharepointdynamics.net/2008/01/how-to-add-a-new-list-item-to-sharepoint-using-the-list-item-web-service/
Yes, i log in with DOMAIN\first.last

I'll have a look at the Sharepoint link..thanks for that.