0

私は非常に簡単なコードでこの例外を取得し、昇格された特権で実行しています。それはsharepoint 2010にあります

private void ChangeVersioningOnDocumentLibrary(SPListItem item, SPItemEventProperties properties, SPSite site)
        {
            string sitename = item[MeetingsCommon.Constants.FIELDS_TEXT_TITLE_NAME].ToString();
            string prefix = item[MeetingsCommon.Constants.FIELDS_TEXT_TITLE_NAME].ToString().Substring(0, 2);
            bool isConfirmed = item.TaxonomyFieldValueIsGivenValue(properties.AfterProperties, MeetingsCommon.Constants.FIELDS_MEETINGSTATUS_NAME, MeetingsCommon.Constants.TERMVALUE_MEETINGSTATUS_CONFIRMED, 1033);
            bool isPublished = item.TaxonomyFieldValueIsGivenValue(properties.AfterProperties, MeetingsCommon.Constants.FIELDS_MEETINGSTATUS_NAME, MeetingsCommon.Constants.TERMVALUE_MEETINGSTATUS_PUBLISHED, 1033);

            if (isConfirmed)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPWeb web = site.OpenWeb(prefix + "/" + sitename))
                    {

                            if (web.Exists)
                            {
                                web.AllowUnsafeUpdates = true;
                                SPList agendaPoints = web.GetSafeListByName(MeetingsCommon.Constants.LISTS_AGENDAPOINTS_NAME);
                                agendaPoints.EnableModeration = true;
                                agendaPoints.DraftVersionVisibility = DraftVisibilityType.Author;
                                agendaPoints.Update();
                                web.AllowUnsafeUpdates = false;
                            }

                    }
                });
            }
            if (isPublished)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPWeb web = site.OpenWeb(prefix + "/" + sitename))
                    {                    
                        if (web.Exists)
                        {
                            web.AllowUnsafeUpdates = true;
                            SPList agendaPoints = web.GetSafeListByName(MeetingsCommon.Constants.LISTS_AGENDAPOINTS_NAME);
                            agendaPoints.EnableModeration = false;
                            agendaPoints.DraftVersionVisibility = DraftVisibilityType.Author;
                            agendaPoints.Update();
                            web.AllowUnsafeUpdates = false;
                        }                    
                    }
                });
            }
        }
4

1 に答える 1

0

問題は、RunWithElevatedPriviliges の外部からの spsite オブジェクトを使用していたことです。これを機能させるには、内部で spsite オブジェクトを再度作成する必要があります。

于 2013-04-09T07:33:55.757 に答える