SPFieldLookup Property LookupWebId Update Security
- From: "kenny" <kkimusa@xxxxxxx>
- Date: 24 Oct 2006 14:47:53 -0700
Hello,
I am trying to create a list which has a lookup field to refer to the
root
site list.
With RunWithElevatedPrivileges, it does not allow.
Please help me.
Kenny.
Guid rootWebId = spSite.RootWeb.ID;
// Product in Service Logs
SPList spListServiceLogs = subWeb.Lists["Service Logs"];
SPSecurity.RunWithElevatedPrivileges(
delegate()
{
SPFieldLookup spProductFieldLookup =
(SPFieldLookup)spListServiceLogs.Fields["Product"];
spProductFieldLookup.LookupList =
spWeb.Lists["Products"].ID.ToString();
spProductFieldLookup.LookupWebId = rootWebId;
spProductFieldLookup.Update();
});
[System.UnauthorizedAccessException] {"Access is denied. (Exception
from
HRESULT: 0x80070005
(E_ACCESSDENIED))"} System.UnauthorizedAccessException
<StackTrace>
at
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException
ex)\r\n
at Microsoft.SharePoint.Library.SPRequest.GetAllWebsOfSite(String
bstrUrl,
Object& pvarWebs, Object& pvarWebIds, Object& pvarParentWebs, Object&
pvarLangs, Object& pvarTitles)\r\n
at
Microsoft.SharePoint.SPSite.SPWebCollectionProvider.GetWebsData(String[]&
strNames, String[]& strServiceRelUrls, Guid[]& guidWebIds, Int32[]&
nLanguages, String[]& strTitles, String[]& strDescriptions, String[]&
strCreationTimes, String[]& strModifiedTimes, Boolean[]&
bUserIsWebAdmins,
Int32[]& nWebTemplates, Int16[]& nProvisionConfigs, Int16[]&
nMeetingCounts)\r\n
at Microsoft.SharePoint.SPWebCollection.EnsureWebsData()\r\n at
Microsoft.SharePoint.SPWebCollection.get_Item(Guid id)\r\n
at Microsoft.SharePoint.SPFieldLookup.set_LookupWebId(Guid value)\r\n
at
Microsoft.SharePoint.Office.WebControls.CreateProjectButton.<>c__DisplayClass1.<updateGlobalLookupField>b__0()
in C:\\SharePoint\\CreateProjectButton.cs:line 188
.
- Follow-Ups:
- Re: SPFieldLookup Property LookupWebId Update Security
- From: Engelbert
- Re: SPFieldLookup Property LookupWebId Update Security
- Prev by Date: Re: wss3
- Next by Date: Simple Question
- Previous by thread: Moved to SQL Server, MSDE Uninstalled: Unable to connect to database
- Next by thread: Re: SPFieldLookup Property LookupWebId Update Security
- Index(es):