5

I have a small GUI Extension that opens a popup from the context menu using this javascript code:

Extensions.Popup.prototype._execute = function Popup$_execute(selection) {
    selectedItem = selection.getItems()[0];
    // build the URL for our popup
    var host = window.location.protocol + "//" + window.location.host;
    var params = "?uri=" + selectedItem;
    var url = host + '/WebUI/Editors/AdminToolPopup/default.aspx' + params;
    var popup = $popup.create(url, "toolbar=no, width=600px, height=200px, resizable=false, scrollbars=false, null);
    popup.open();         
}

The popup is a small .Net Web application using the Core Service, with bindings specified in a web.config file located in the extension folder.

I get an impersonation error message from the Core Service. Is it a problem with the web.config being there? Do I need a config-less Core Service?

Error from popup:

System.IdentityModel.Selectors.PolicyValidationException: The incoming policy could not be validated. For more information, please see the event log. Server stack trace: at System.IdentityModel.Selectors.ExceptionHelper.ThrowIfCardSpaceException(Int32 status) at System.IdentityModel.Selectors.CardSpaceSelector.GetToken(CardSpacePolicyElement[] policyChain, SecurityTokenSerializer tokenSerializer) at System.ServiceModel.Description.ClientCredentials.GetInfoCardSecurityToken(Boolean requiresInfoCard, CardSpacePolicyElement[] chain, SecurityTokenSerializer tokenSerializer) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink) Exception rethrown at [0]: at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.DisplayInitializationUI() at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [1]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService.Impersonate(String userName) at Tridion.Web.CMUtils.CMSession.get_CoreServiceClient() at Tridion.Web.UI.Models.TCM54.TcmAuthorizationModule.OnAuthorizeRequest(Object sender, EventArgs e) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

5

I'm tempted to say: "you are doing it all wrong", since I believe it not expected to use ASP.NET code directly in an Editor extension, but rather place that in a Model extension and call it from your Editor via JavaScript. For more details see one of my examples here, where I have the Core Service stuff in the Model and call it in the Editor via JavaScript.

But that wouldn't really be answering it, just solving it differently. I guess it is a bit depending on what you are actually doing exactly, like how do you create your Core Service client etc.?

Since you are on the CM server and inside the Core application, you don't need to configure the core service, you can just use what is already configured. In my Model extension I instantiate a Core Service client using the following class and method:

using Tridion.ContentManager.CoreService.Client;

namespace Example.UiCoreService.Model.CoreService
{
  public class Client
  {
    public static SessionAwareCoreServiceClient GetCoreService()
    {
      var client = new SessionAwareCoreServiceClient("netTcp_2012");
      client.Impersonate(Tridion.Web.UI.Core.Utils.GetUserName());
      return client;
    }
  }
}

There is no further configuration needed, since the SDL Tridion CME web.config already defines the netTcp_2012 binding (on 2013 SP1, for other versions a different binding will be there) so you should be able to use it directly. Similar to the impersonation, you can simply use the current logged in user for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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