I'm using forms authentication to log in into windows sharepoint servevices 3.0 service. I need to elevate during anonymous access, rights to add record to sharepoint portal list.
I found clue in msdn: http://msdn.microsoft.com/en-us/library/bb466220%28classic%29.aspx
But it doesn't work for me. :( It's still calling for user login and password.
Can anybody help me please?
Public Function AddUserAccountData() As String
SPSecurity.RunWithElevatedPrivileges(AddressOf AddUserAccountDataToSPList)
Return ""
End Function
Private Sub AddUserAccountDataToSPList()
Dim oSharedConfig As SharedConfig = SharedConfig.Instance
Dim sListName As String = oSharedConfig.oWebPartsOpt.UserOpt.AccountVerificationList.Name
Using oSite As SPWeb = SPContext.Current.Web
Dim oUserAccStatusList As SPList = oSite.Lists(sListName)
oUserAccStatusList.Items.Add()
Dim oSPListItem As SPListItem = oUserAccStatusList.Items.Add()
oSPListItem("one") = _sUserLogin
oSPListItem("two") = _sUserGuid
oSPListItem("three") = False
oSPListItem("four") = DateTime.Now
oSPListItem.Update()
End Using
End Sub
RunWithElevatedPrivileges
, opens the site and adds the item? – Kobi