Question

I have a Tridion Core Service Web Application to publish pages. When logged into the server and running it from there via a browser client calling a web service with ajax it works fine. However, when I run the application from my desktop it does nothing, and also throws no error messages.

*Edit: The Web App hosting the web service is running as an 'Application' under the Tridion 2011 CMS website. This is done to avoid cross-domain ajax issues/

  • Update: The code below is working fine - both with the impersonate and also with Nick's solution. My issue was actually in how I was calling the web service from jQuery and using the appropriate URL. I am leaving the code and question so maybe it will help others.

My code is:

string binding = "wsHttp_2011";
using (var client = new SessionAwareCoreServiceClient(binding))
{
    client.Impersonate("company\\cms_svc");

    // ** Get Items to Publish
    List<string> itemsToPublish = GetItemsToPublish(publishItem.TcmUri, client);

    PublishInstructionData instruction = new PublishInstructionData
    {
        ResolveInstruction = new ResolveInstructionData() { IncludeChildPublications = false },
        RenderInstruction = new RenderInstructionData()
    };

    PublicationTargetData pubtarget = (PublicationTargetData)client.Read(publishItem.PubTargetUri, readoptions);
    List<string> target = new List<string>();
    target.Add(pubtarget.Id);

    client.Publish(itemsToPublish.ToArray(), instruction, target.ToArray(), GetPublishPriority(publishItem.Priority), readoptions);
}
Was it helpful?

Solution

Have at look at this page on SDL Live Content, which explains various types of scenarios for connecting as different users:

http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/task_87284697A4BB423AAD5387BBD6884735

As per the docs, instead of impersonation you may want to establish your Core Service connection as follows using NetworkCredential:

using (ChannelFactory<ISessionAwareCoreService> factory = 
  new ChannelFactory<ISessionAwareCoreService>("netTcp_2011"))
{
  NetworkCredential networkCredential = 
   new NetworkCredential("username", "password", "domain");
  factory.Credentials.Windows.ClientCredential = networkCredential;
  ISessionAwareCoreService client = factory.CreateChannel();
  Console.WriteLine(client.GetCurrentUser().Title);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top