Question

Hi i am trying to connect to Tridion through core service by using another person credentials using following code:

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);

but i am getting eror:

Could not connect to net.tcp://localhost:2660/CoreService/2011/netTcp. The connection attempt lasted for a time span of 00:00:01.0310784. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:2660

No correct solution

OTHER TIPS

To answer your question, using netTcp for a remote client is only possible if port 2660 is open. So if you are unsure about the firewall restrictions, you might be better off using the wsHttp or basicHttp bindings.

Additionally, the one thing i'm not getting is that you are using the Session Aware Core Service Client and you are trying to supply a password. That doesn't really add up for me, in my opinion the Session Aware Core Service Client is supposed to be used in a situation where your user account is already authenticated against SDL Tridion, or when you are calling the Core Service though a valid SDL Tridion Impersonation user. Upon which you impersonate the Core Service call to a valid SDL Tridion username by just the username (no password required there). You can supply credentials (username and password) for the SessionAwareCoreServiceClient, but then you have to supply the credentials of a valid SDL Tridion impersonation user, and still you have to impersonate then.

I would suggest to try using the regular Core Service Client as explained here: Get Core Service Client without config file.

Or if you insist on using the Session Aware Core Service Client (which I think is wrong in your case), make sure your application is running under a valid SDL Tridion Impersonation user (if you are running on an external server you need to add a domain account for that in the SDL Tridion MMC snap-in Impersonation users) and then impersonate the core service client like so:

using (SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient())
{
  // impersonate with valid user
  client.Impersonate("SDL Tridion Username here");
  // use client
  client.Delete(...);
}

But you still will have to choose the correct bindings of course.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top