Updating sharepoint list with security privileges

when adding an item to the sharepoint list, security privileges may be required. Otherwise, it will prompt for the user name and password, on every time the page loads.

So in the following code, I am calling the function “testfunction” under security privileges

webContext = SPContext.Current.Web
SPSecurity.RunWithElevatedPrivileges(New SPSecurity.CodeToRunElevated(AddressOf TestFunction))

Then in the TestFunction, the current web can be get only by using “webContext.Site.ID”.

ie.

function TestFunction

Using site As New SPSite(webContext.Site.ID)
Dim web As SPWeb = site.OpenWeb(webContext.ID)
Dim lstColl As SPListItemCollection
——-

——

end using

end function

Advertisement

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.