3

We were trying to use ECL service to get list of all stub URIs or generate them if they are not already generated.

Update: I do have specific need where we have some new ECLs in a specifc folder that we want to use in some of our Components, doing it manually is taking time. I see that when I link new ECLs to my Component using Core Service, they do not give me output of URLs if the ECL does not have a stub URI. It seems I can only link a stub URI to the Component and then only I will have proper ECL linked and my Template Builder gives desired results. Hence before doing it I need to first generate their stubs and then link those stubs to my Component.

I am using below code block:

try
{
    ISessionAwareEclService eclService = new SessionAwareEclServiceClient();
    NetworkCredential networkCredential = new NetworkCredential(username, password);
    eclService.Impersonate(username);
    var types = eclService.GetDisplayTypes();
    var stubUris = eclService.CreateOrGetStubUris(eclUris);
}
catch (Exception e)
{
    Log.Error("Exception: ", e);
}

The binding information are as below:

<netTcpBinding>
    <binding name="netTcp" transactionFlow="true" transactionProtocol="WSAtomicTransaction11" maxReceivedMessageSize="2147483647">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
    </binding>
    <binding name="streamDownload_netTcp" maxReceivedMessageSize="2147483647" transferMode="StreamedResponse" sendTimeout="00:20:00"/>
    <binding name="streamUpload_netTcp" maxReceivedMessageSize="2147483647" transferMode="StreamedRequest" receiveTimeout="00:20:00"/>
    <!-- ECL Binding -->
    <binding name="EclNetTcpBinding" maxReceivedMessageSize="10485760" receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <readerQuotas maxArrayLength="10485760" maxStringContentLength="10485760" />
    </binding>
</netTcpBinding>

And Client is created as below:

<client>
  <!-- ECL Client -->
  <endpoint name="eclNetTcp_2012" address="net.tcp://<our-tridion-hostname>:2660/ExternalContentLibrary/2012/netTcp" binding="netTcpBinding" bindingConfiguration="EclNetTcpBinding" contract="Tridion.ExternalContentLibrary.Service.Client.ISessionAwareEclService"/>
</client>

Note: The user used to connect is the same user that is configured in the ECL.config. We have tried with other Admin users as well.

While trying to connect with that I am getting below error in application:

14:31:25.393|ERROR|CommunicationException: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: msgAccessDeniedForImpersonationUser (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: Tridion.Infrastructure.Exceptions.LocalizableSecurityException: msgAccessDeniedForImpersonationUser at Tridion.ExternalContentLibrary.Service.EclService2012.AssertIsImpersonationUser(String name) at Tridion.ExternalContentLibrary.Service.EclService2012.InitializeUserContext(String impersonationName) at CreateTridion.ExternalContentLibrary.Service.EclService2012() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)).

In Media Manager Logs:

2017-11-16T09:15:01 TcmServiceHost 680 msgAccessDeniedForImpersonationUser at Tridion.ExternalContentLibrary.Service.EclService2012.AssertIsImpersonationUser(String name) at Tridion.ExternalContentLibrary.Service.EclService2012.InitializeUserContext(String impersonationName) at CreateTridion.ExternalContentLibrary.Service.EclService2012() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

in Event Viewer:

msgAccessDeniedForImpersonationUser StackTrace Information Details: at Tridion.ExternalContentLibrary.Service.EclService2012.AssertIsImpersonationUser(String name) at Tridion.ExternalContentLibrary.Service.EclService2012.InitializeUserContext(String impersonationName) at CreateTridion.ExternalContentLibrary.Service.EclService2012() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

Also on "msgAccessDeniedForImpersonationUser" errro I tried: ServiceActivationException when deploying Flickr ECL Provider But no luck.

Can any one please help me with ECL Service.

I am curious, is this not the way I should use this?

I looked around and got more references from here about ECL Service:

Creating ECL multimedia Components using Core Service Web 8

https://community.sdl.com/product-groups/sdl-tridion-dx/tridion-sites/tridion-developer/b/weblog/posts/uploading-images-from-sdl-web-tridion-to-sdl-media-manager

ServiceActivationException when deploying Flickr ECL Provider

2 Answers 2

3

I think it is related to how you instantiate and use the SessionAwareEclServiceClient, try doing the following:

// services endpoints and binding 
// (I've copied them from an old example, make sure to update them to your version)
EndpointAddress eclServiceEndpoint = new EndpointAddress("net.tcp://localhost:2660/ExternalContentLibrary/2012/netTcp");
NetTcpBinding binding = new NetTcpBinding
{
    MaxReceivedMessageSize = 2147483647,
    ReaderQuotas = new XmlDictionaryReaderQuotas
    {
        MaxStringContentLength = 2147483647,
        MaxArrayLength = 2147483647
    }
};

// ecl service client
var eclServiceClient = new SessionAwareEclServiceClient(binding, eclServiceEndpoint);
eclServiceClient.Impersonate("domain\\user");

I've simplified the code for the example, feel free to add a try catch block around it again of course. But the most important thing is that the SessionAwareEclServiceClient is running under the user that your program is running under, and this user must be a (configured) impersonation user. Then you can impersonate with simply the username, you don't need a password or additional network credentials.

For the ECL service you can't connect using your own credentials like with the Core Service clients. So even when using EclServiceClient, make sure the program is run under a valid Tridion user or Impersonation user (and impersonate to a valid Tridion user).

Also don't forget to properly close the service client when you are done:

Close(eclServiceClient);

private static void Close(ICommunicationObject client)
{
    try
    {
        if (client.State != CommunicationState.Faulted)
        {
            client.Close();
        }
    }
    finally
    {
        if (client.State != CommunicationState.Closed)
        {
            client.Abort();
        }
    }
}

Oh and one final note, you start of your question with the following information:

We were trying to use ECL service to get list of all stub URIs or generate them if they are not already generated.

While this is a perfectly fine scenario, I do hope it is related to a specific list of URIs you are trying to get for a specific reason. Since if you are trying to use it to generate a stub for every available ECL item, then I think it might become quite a heavy and unneeded action. Stub Components are normally created on the fly once an ECL item is being used. There certainly are use cases where you call the method CreateOrGetStubUris, but you shouldn't call it unless you are actualy going to need those URIs of course. I'm just adding this since your question doesn't make it clear why you are using this.

update

ECL is basically an extension to Tridion that adds some capability to the Tridion core via Event handlers and UI extensions, the Core Service itself is indeed not aware of this. So when trying to link a ECL Component via the Core Service, you should indeed call the CreateOrGetStubUris method yourself.

I would suggest that you embed the ECL service call for this in your Core Service program, and call the method for each link you are trying to make, rather than calling a separate program and simply creating a whole bunch of ECL stub Components in one go, when you might not even be using all of them. Please note it is absolutely fine to use the method for a bulk call, that is what it is made for, I'm only advising against using it to create stubs for every known item, you should really only call it for items that you are planning to use.

Other than that the error you described is simply an impersonation issue, follow the rules of Impersonation in Tridion and you should not have any issues there.

4
  • Thanks Bart, the code I had shared is just the snippet which actually connects with service. I already have a class which does all these to handle the connection properlly. I kind of found the issue, Its my user and some more users.. I used an old credenatial from team and i am able to connect. I am still tryig to find the diff between these user settings and will update once found. Nov 18, 2017 at 7:39
  • And also, yes I do have some list of few hundreds ecl uris that I am creating stubs before linking them to some new coponents. Nov 18, 2017 at 8:23
  • @VikasKumar any reason why you are creating the stubs yourself and not letting the system create them? Don't answer here but edit your question with the updated information Nov 18, 2017 at 8:30
  • What fixed my problem was - After adding user as impersonate, I had to start COM Apps. Tried this in Dev and Test and they seem to work. Dec 15, 2017 at 8:40
0

User that execute this code is not configured as impersonation user in CM.

In order to impersonate somebody user that calling Impersonate must be configured as impersonation user in CM.

P.S. Too bad people do not know basics of Tridon

3
  • Thanks Yuri, user using this code is already set as impersonate user. But I'll do cross check this. Nov 17, 2017 at 10:43
  • Yuri - no need to be rude on your answer. We're here to help.
    – Nuno Linhares
    Nov 17, 2017 at 12:03
  • Yuri, maybe you can edit your answer and explain Impersonation and its configuration in more detail, since I agree that it is a shame that too many people still don't seem to get it. Dec 15, 2017 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.