none
UpdateListItem method and System Account RRS feed

  • Question

  • Hi

    I've developed a Help Desk application in Visual Studio that uses a Sharepoint List to store the data.

    My problem is that when i use the UpdateListItems method for submitting a new record, Sharepoint automatically assigns to the "Created By" (Author) field as "System Account" and this prevents the trigger of a workfow i created with Sharepoint Designer.
    I've tried to force the Created By field during submit by adding to my batch <Field Name='Author'>person id;#person username</Field>

    but it will still show "System Account"!!

    Any ideas!?

    sorry for my bad english:(
    • Edited by Pizzaware Thursday, January 21, 2010 12:31 PM
    Thursday, January 21, 2010 11:40 AM

Answers

  • thank u all for the answers, i've solved this by using microsoft.sharepoint namespace instead of the web services and i submit the item by impersonating the user that i want
    heres the code:

     

    Dim aSite As New SPSite("sharepoint server URL")
    Dim targetWeb As SPWeb = aSite.OpenWeb()
    Dim token As SPUserToken = targetWeb.AllUsers("username").UserToken

     

    Using impersonatedSite As New SPSite("sharepoint server URL", token)
            targetWeb.AllowUnsafeUpdates =
    True
            Dim lista As SPList = targetWeb.Lists("ListName")
            Dim newItem As SPItem = lista.Items.Add()
            newItem(
    "Title") = "value"

            'rest of the code

            newItem.Update()
            targetWeb.AllowUnsafeUpdates =
    False
    End Using

    • Marked as answer by Pizzaware Friday, January 22, 2010 9:49 AM
    Friday, January 22, 2010 9:49 AM

All replies

  • Hi,

    Can you plz post your code? It seems you are running the code for adding list item under system account. It may happen if you use SPSecurity.Evelvated.. or a SP Object that is opened under system account.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com
    Thursday, January 21, 2010 11:51 AM
  • i'm not using microsoft.sharepoint namespace so there arrent any SP Objects ...i only use SharePoint Web Services

    anyway to connect to the list i use

    "listWebServiceRefernece".Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

    Thursday, January 21, 2010 12:36 PM
  • another important thing is that i run my application on the same server where my sharepoint site is hosted...
    so the code is executed by the server administrator that is the application pool account for sharepoint... could this be the problem?
    Thursday, January 21, 2010 3:09 PM
  • It could be the problem. Try executing your code with login other than server administrator. It should work in that case.
    Friday, January 22, 2010 6:23 AM
  • thank u all for the answers, i've solved this by using microsoft.sharepoint namespace instead of the web services and i submit the item by impersonating the user that i want
    heres the code:

     

    Dim aSite As New SPSite("sharepoint server URL")
    Dim targetWeb As SPWeb = aSite.OpenWeb()
    Dim token As SPUserToken = targetWeb.AllUsers("username").UserToken

     

    Using impersonatedSite As New SPSite("sharepoint server URL", token)
            targetWeb.AllowUnsafeUpdates =
    True
            Dim lista As SPList = targetWeb.Lists("ListName")
            Dim newItem As SPItem = lista.Items.Add()
            newItem(
    "Title") = "value"

            'rest of the code

            newItem.Update()
            targetWeb.AllowUnsafeUpdates =
    False
    End Using

    • Marked as answer by Pizzaware Friday, January 22, 2010 9:49 AM
    Friday, January 22, 2010 9:49 AM