我想允许匿名用户在 SharePoint 中上传文件。在做了一些研究之后,我写了这个代码来允许匿名用户上传。但匿名用户无法登录并被要求登录。请帮助我。我的代码有什么问题?
public string CreateSPFilet(string spServerURL, string tempLibrary, string folder, Stream fileStream, bool overwrite)
{
string strError = "";
string fileName = "";
try
{
if (!SPSite.Exists(new Uri(spServerURL)))
{
strError += ERROR01;
}
else
{
SPSite tempSite = new SPSite(spServerURL);
SPUserToken systoken = tempSite.SystemAccount.UserToken;
using (SPSite site = new SPSite(spServerURL, systoken))
{
SPWeb oWebsite = site.OpenWeb();
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite elevatedSite = new SPSite(site.ID))
{
using (SPWeb eevatedWeb = elevatedSite.OpenWeb(oWebsite.ID))
{
oWebsite.AllowUnsafeUpdates = true;
string targetUrl = SPUrlUtility.CombineUrl(oWebsite.ServerRelativeUrl, tempLibrary);
SPFolder target = oWebsite.GetFolder(targetUrl);
SPFileCollection files = target.Files;
SPFile file = target.Files.Add(fileName, fileStream, overwrite);
oWebsite.AllowUnsafeUpdates = false;
}
}
});
}
}