1

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
Andrey Marchuk
  • 13,301
  • 2
  • 36
  • 52
Aquarius24
  • 1,806
  • 6
  • 33
  • 61

1 Answers1

4

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.

Bart Koopman
  • 4,835
  • 17
  • 30
  • I do not entirely agree with you, Bart. First of all there's no non SessionAwareClient in TridionServiceHost, and configuring LDAP on TCMServiceHost is not supported (but possible), so no problem here. It should still work with username and password. One reason to use it is that net.tcp is way faster than other transport methods. – Andrey Marchuk Jan 17 '13 at 12:14
  • And this is not an answer to the question, so downvote, sorry – Andrey Marchuk Jan 17 '13 at 12:16
  • not sure what you mean with there's no non SessionAwareClient in TridionServiceHost, because there is the CoreServiceClient and the SessionAwareCoreServiceClient. In my opinion the SessionAwareCoreServiceClient should only be used with impersonation, the regular one you can use with direct credentials of a SDL Tridion user. And the answer to the question is given in the first line where I state he must have port 2660 open. – Bart Koopman Jan 17 '13 at 12:52
  • 1
    SessionAwareCoreServiceClient can be used with NetTcp and WsHttp, and it can be used with any user (you can call client.Impersonate("username") for instance). The session that the client is aware of is the session on the server, as it keeps that same session alive between requests until you explicitly disconnect. – Nuno Linhares Jan 17 '13 at 13:13
  • I was trying to say that there's no CoreServiceClient over net.tcp – Andrey Marchuk Jan 17 '13 at 13:29
  • see [this article](http://code.google.com/p/tridion-practice/wiki/GetCoreServiceClientWithoutConfigFile), at the bottom you see there is one – Bart Koopman Jan 17 '13 at 14:15
  • No, there's no, check config - endpoint netTcp is of contract ISessionAwareCoreService2011 – Andrey Marchuk Jan 17 '13 at 14:58
  • what config are you referring to? – Bart Koopman Jan 17 '13 at 15:38
  • Tridion\bin\TcmServiceHost.config.exe, the one that is hosting netTcp enpdoints – Andrey Marchuk Jan 18 '13 at 07:46