c# - System.UnauthorizedAccessException was unhandled by user code in simple code -
I got this exception in very easy code and I'm running it with elevated privileges around it. This is in SharePoint 2010
Private Zero ChangeVersioningOnDocumentLibrary (SPListItem item, SPItemEventProperties property, SPSite site) {string sitename = item [MeetingsCommon.Constants.FIELDS_TEXT_TITLE_NAME] .toString (); . String prefix = items [MeetingsCommon.Constants.FIELDS_TEXT_TITLE_NAME] .ToString () substrings (0, 2); Bool Isconfirmed = Aitmktaksonomifieldwlusgivenvlua (Proprtijkaftrproperthys, Mitingskmonkkonstentskfailds_mitingstatus_nam, Mitingskmonkkonstentsktrmvlua_mitingstatus_knfrmd, 1033); Bool Ispublised = Aitmktaksonomifieldwlusgivenvlua (Proprtijkaftrproperthys, Mitingskmonkkonstentskfailds_mitingstatus_nam, Mitingskmonkkonstentsktrmvlua_mitingstatus_pblisd, 1033); If (isConfirmed) {SPSecurity.RunWithElevatedPrivileges (delegate () {(SPWeb using web = site.OpenWeb (prefix + "/" + sitename)) {if (web.Exists) {web.AllowUnsafeUpdates = true SPList agendaPoints = Web . Getsfelisbinme (Mitingskmonkkonstentsklists_agendapoints_nam); Agendapoints.anblemodersn = True Agendapointskdraftversionvisibiliti = Draftvisibilititeepekothr; Agendapointskapdet (); Vebkallovunsafupdtes = false;}}}); } If (isPublished) {SPSecurity.RunWithElevatedPrivileges (using representative () {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;}}}); }}
The problem is that it comes using a spsite object from RunWithElevatedPriviliges Having had the spsite object to work for this to be built again in.
Comments
Post a Comment