0

Recently I am developing a webservice which is used to upload document to a SharePoint doc library. I have deploy it to the _vti_bin directory and now I can successfully call it to upload a document. However, no matter what I use as username and password, the owner of upload document is still System Account. It shows in the site as modified by System Account. I refer to "Walkthrough: Creating a Custom ASP.NET Web Service (Eng version)" to develop and deploy webservice. The code for calling the webservice is the following:

string FileUrl = "d:/bbb.txt";
sharepoint_0907.Service ss = new sharepoint_0907.Service();
ss.Credentials = new NetworkCredential(username, password, domain);
byte[] fileContents = System.IO.File.ReadAllBytes(@FileUrl);
int s = ss.UploadFile("http://sharepoint01/Shared Documents/", 
                       fileContents, "http://sharepoint01", "123.txt");
string ddd = ss.HelloWorld();

So I can successfully upload a document with view user who has not have authority to upload a document. And this is not what I want. Can anyone help me with this?

2 Answers 2

2

If you have elevated code you get System Account as modifier of the documents. Also if you have Claims based authentication it makes things more complicated.

I was struggling with similar issues to get correct authentication in web-service calls. The msdn article you are using is not too easy to follow - I was using this blog post by Arjun Chakraborty, except the part where you push web.config with deploy to the hive and overwrite the existing ISAPI web.config - just edit the web.config manually. Also I used a binding TextStreamBindingNoSecurity that SharePoint built-in web-services uses. This also works for https using TextStreamBindingHttpsNoSecurity binding.

0

Would using the OOB Copy Web Service help you get rid of custom Web Service and also fix this issue? Example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.