I am not sure what you mean to assign to campaign, as campaigns use marketing lists.
Regarding assigning the ownership of a record to a particular entity you can use the following code:
/// <summary>
/// Changes the Ownership of a record
/// </summary>
/// <param name="entityname">The name of the entity that is being assigned to</param>
/// <param name="id">The Guid of the entity record that is being assigned to</param>
/// <param name="ownerid">The user unique id that is becoming the assignee</param>
public void AssignOwnership(string entityname, Guid id, Guid ownerid)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference(entityname, id);
request.Assignee = new EntityReference("systemuser", ownerid);
try
{
AssignResponse response = (AssignResponse)service.Execute(request);
}
catch (FaultException<OrganizationServiceFault> ex)
{
tracingService.Trace("Error Assigning Record: {0}", ex.Message);
throw new InvalidPluginExecutionException(ex.Message);
}
}
To call the function your basically specify the entity name, entity id and user id
If you use the LocalPluginContext for example, you can set it like this:
string entityName = localContext.PluginExecutionContext.PrimaryEntityName;
Guid entityId = localContext.PluginExecutionContext.PrimaryEntityId;
Guid userId = localContext.PluginExecutionContext.UserId;
AssignOwnership(entityName, entityId, userId);
Hope this helps.