Default Server Event - Connect to SharePoint

  • 19 October 2005
  • 2 replies
  • 0 views

Badge +4
Hi,

In an activity, there is a Default Server event which connect to SharePoint to add a discussion b(y a method from a dll). The code of adding to discussion in this dll is the following:

public void insertIntoIPDiscussion(string strSPSURL, string strIPDiscussionName, string strSubject, string strText, string strPostedBy)
{
if (strSubject != "" && strText != "")
{
SPSite siteCollection = new SPSite(strSPS);
SPWeb site = siteCollection.AllWebs[""];
SPListItemCollection listItems = site.Lists[strIPDiscussionName].Items;

SPListItem item = listItems.Add();

//item["Posted By"] = strPostedBy;
//item["Modified By"] = strPostedBy;
item["Subject"] = strSubject;
item["Text"] = strText;

try
{
item.Update();
}
catch(Exception ex)
{}
}
}

It's OK except the "Posted By" is "k2service" - the user that starts K2Server. I try to change "Posted by" value but it not run.
What can I do to change this to an user I can specify? Thanks.

2 replies

Badge +9
The SPS Object model does not allow one to specify the Posted By , this is auto populated with the actual account that executes the action. K2.net Server runs in the context of the Startup user account and that is the reason why that account is specified.
Badge +4
Hi,
Thanks for your reply.
I've already known the reason why the account "k2service" (the user I created for starting K2.net Server) is the value of "Posted By" of my Discussion. And I know that "Posted By" can not be specified manually (after trying to change it's value).

So my question was: When add a new discussion in K2.net Studio (A Default Server event), what can I do to pass the credential (Posted By) to an user I can specify (in my method is "strPostedBy") - not by the user who starting K2.net Server (or to the destination user of the activity including the Default Server event)? Thanks.

(SPS 2003 list event can only access List but can not access Dicussion, :().

Reply