1

特別なSharepointページでホストされているascxカスタムコントロール(Webパーツではない)があります。このページでは、ユーザーがサーバーにファイルをアップロードできます。残念ながら、アクセス許可の問題により、Sharepointがファイルをネットワーク上の場所に保存できません。

Sharepoint 2007ベースのサイトのアプリケーションプールに起因するネットワークアカウントには、その場所に付与された「変更」および「読み取り」アクセス権があります。

アプリケーションプールアカウントで使用される資格情報を使用して別のマシンにログインし、指定されたネットワークの場所に問題なくディレクトリとファイルを作成できます。

SharepointがIIS7のアプリケーションプールに設定されているファイルではなく、他のアカウントを使用してこれらのファイルを保存しようとしている可能性はありますか?

発生しているエラー:

メッセージ:パス'\ opal \ gwl \ pictures\L36'へのアクセスが拒否されました。

スタックトレース: System.IO.__Error.WinIOError(Int32 errorCode、String mayFullPath)at System.IO.Directory.InternalCreateDirectory(String fullPath、String path、DirectorySecurity dirSecurity)at System.IO.Directory.CreateDirectory(String path、DirectorySecurity directorySecurity )ECan.SharePoint.Web.Applications.MyECan_WaterMeterFormDatalogger.SavePhotos()で

例外タイプ: System.UnauthorizedAccessException

ユーザー:システムアカウント

ascxコードビハインドファイルのSavePhotos関数のコード:

protected void SavePhotos()
{
    string wellNo = WellNo.Value;
    string epoWaterMeterID = EPO_WaterMeterID.Value;
    string dirRoot = ConfigurationManager.AppSettings["PhotoDir"];
    string map = wellNo.Substring(0, wellNo.IndexOf('/'));

    int photoSaveCount = 1;
    foreach (string filePath in Request.Files)
    {
        HttpPostedFile file = (HttpPostedFile)Request.Files[filePath];
        if (file.InputStream.Length > 0)
        {
            try
            {
                // Create dir if does not exist
                string dir = dirRoot + map;
                if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);

                // Save file
                file.SaveAs(dir + @"\" + wellNo.Replace('/', '_') + "-" + epoWaterMeterID.ToString() + "-" + photoSaveCount.ToString() + ".jpg");

                photoSaveCount++;
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }
    }
}

誰かが問題が何であるかについて何か考えを持っていますか?

4

2 に答える 2

1

昇格した特権で SavePhotos を呼び出す必要があると思います。昇格された特権でコードを実行すると、ユーザーがフル コントロールを持っていない場合でも、指定されたメソッドがフル コントロール権限で実行されます。

リンクを参照してください:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges(v=office.12).aspx

以下のコードを試してください。

protected void Button1_Click(object sender, EventArgs e)
{
   SPSecurity.CodeToRunElevated elevatedGetSitesAndGroups = new SPSecurity.CodeToRunElevated(SavePhotos);
   SPSecurity.RunWithElevatedPrivileges(elevatedGetSitesAndGroups);
}
于 2012-06-25T04:42:14.770 に答える
0

新しく作成したディレクトリまたはフォルダの権限を設定しようとしましたか? これを行うには、System.Security.AccessControl 名前空間内の DirectorySecurity クラス、具体的にはそのクラスの SetAccessControl メソッドを使用します。

于 2012-06-26T04:25:59.877 に答える