开发者

How to pass user credentials to sharepoint using SP Object Model instead of web service while uploading file

I want to upload files in a document library of sharepoint site (WSS 3.0) using c#, but the problem is that I want to allow only authorized users to upload file. I don't know how to pass user credentials using sharepoint开发者_运维知识库 object model. Is there a way to get user credentials from user i.e username, password and then upload file using these credentials. I am asking this because if i use elevated prevelages then I don't know who uploaded the file because file uploaded as system account.


Normally whenever you upload a file to SharePoint library its done using current logged in user context so if any user who has not got sufficient rights will not be able to upload a file and you will get a exception for the same in the code


It needs to be custom code and wouldn't be available out of the box.

One approach. You can pass the username to the routine that does the file uploading. You can then enumerate the site users to see a) if the user exists on the site and b) do they have the proper rights to add the document.

Look at the AllUsers property on the SPWeb object (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.allusers.aspx)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜