Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to follow WCF delegation example on MSDN but keep getting "impersonation level" exception
    primarykey
    data
    text
    <p>Near the bottom of this article (<a href="http://msdn.microsoft.com/en-us/library/ms730088.aspx" rel="nofollow noreferrer">MSDN</a>) in a section entitled "The following code example demonstrates how to use delegation." where MSDN shows an example of how to perform delegation. I have tried to take this example and apply it to my code. In my situation, I have a client app (WCFTestClient), a middle service and a back end service. The goal is is to have the client execute a WCF exposed method on the middle service which in turn calls another method on the back end service. I'm trying to get the identity of the execution on both middle service and back end service to be that of the user executing the client:</p> <p>Client ----> Middle Service ----> Back End Service.</p> <p>Here is the exception that occurs on the "channel.PreparePolicy" invocation:</p> <p><strong>Could not load file or assembly 'System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)</strong></p> <p>Here is my code, taken most directly from the example. I did add one line that differs from the MSDN example in my attempt to debug <code>channelFactory.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation;</code><br> but to no effect.</p> <pre><code> [OperationBehavior(Impersonation = ImpersonationOption.Required)] public void PreparePolicy(string requestGuid, string policyName, ulong version) { WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity; if (callerWindowsIdentity == null) { throw new InvalidOperationException ("The caller cannot be mapped to a Windows identity."); } using (callerWindowsIdentity.Impersonate()) { NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Message; Uri uri = new Uri(String.Format("net.tcp://{0}:{1}/App", "10.192.12.159", 8080)); EndpointAddress backendServiceAddress = new EndpointAddress(uri); ChannelFactory&lt;Service&gt; channelFactory = new ChannelFactory&lt;Service&gt;(binding, backendServiceAddress); channelFactory.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation; Service channel = channelFactory.CreateChannel(); channel.PreparePolicy("alkdjf", policyName, version); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload