Invalid token for impersonation - it cannot be duplicatedInvalid token for impersonation - it cannot be duplicated
Old forum URL: forums.lhotka.net/forums/t/505.aspx
madsgonzo@hotmail.com posted on Thursday, June 29, 2006
Hi
I´m having problems using CSLA with remoting. I get a "Invalid token
for impersonation - it cannot be duplicated" from the RemotingProxy
(Return Portal.Fetch(objectType, criteria, context)). The app works
great in local mode and when I navigate to
http://demo2003sql/RemoteHost/RemotingPortal.rem?wsdl I get a whole lot
of XML. I tried the Visual Studio built in IIS, XP IIS and a 2003 IIS
same result.
I hope someone knows what I´m doing wrong.
Thanks to Rockford for the very cool framework.
Mads.
RockfordLhotka replied on Thursday, June 29, 2006
Are you using Windows AD security, or CSLA custom security? More importantly, do you have the CSLA authorization mode set the same on the client's app.config as the web.confing on the server?madsgonzo@hotmail.com replied on Thursday, June 29, 2006
I´m using CSLA, if I change it to Windows the error is gone, unfortunally I can´t use Windows security.
Here is the config files:
<?
xml version="1.0" encoding="utf-8" ?>
<configuration><appSettings>
<add key="CslaAuthentication" value="Csla" />
<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.RemotingProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://localhost:2024/RemoteHost/RemotingPortal.rem"/>
<!--<add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WebServicesProxy, Csla"/>
<add key="CslaDataPortalUrl" value="http://localhost:2218/ServiceHost/WebServicePortal.asmx"/>-->
</appSettings>
</configuration>
---
<?
xml version="1.0"?>
<configuration><appSettings>
<add key="CslaAuthentication" value="CSLA"/>
</appSettings><connectionStrings><add name="imsJournal" providerName="System.Data.SqlClient" connectionString="Data Source=10.0.0.100,1433;Network Library=DBMSSOCN;Initial Catalog=imsArchive;User ID=ims;Password=ims;"/></connectionStrings>
<system.runtime.remoting><application><service><wellknown mode="SingleCall" objectUri="RemotingPortal.rem" type="Csla.Server.Hosts.RemotingPortal, Csla"/></service>
<channels><channel ref="http"><serverProviders><provider ref="wsdl"/><formatter ref="soap" typeFilterLevel="Full"/><formatter ref="binary" typeFilterLevel="Full"/></serverProviders></channel></channels></application></system.runtime.remoting>
<system.web><customErrors mode="Off" /><identity impersonate="false"/><compilation><assemblies><add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation></system.web></configuration>
I hope someone knows what to do?
Mads
RockfordLhotka replied on Thursday, June 29, 2006
Could be a case-sensitivity issue. Your web.config file has Csla as CSLA.madsgonzo@hotmail.com replied on Friday, June 30, 2006
No that diden´t help. The project tracker works fine so i can´t be a machine problem. The same error occurs if I use WebServiceProxy.
Mads
madsgonzo@hotmail.com replied on Friday, June 30, 2006
More error code:
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Invalid token for impersonation - it cannot be duplicated.
at System.Security.Principal.WindowsIdentity.CreateFromToken(IntPtr userToken)
at System.Security.Principal.WindowsIdentity..ctor(SerializationInfo info)
at System.Security.Principal.WindowsIdentity..ctor(SerializationInfo info, StreamingContext context)
--- End of inner exception stack trace ---
madsgonzo@hotmail.com replied on Friday, June 30, 2006
Hi
I have created a simple solution that fails the same way. I hope someone can see what the problem is.
http://mk2.dk/simpletest.zip
Mads
RockfordLhotka replied on Friday, June 30, 2006
The exception indicates that you are somehow attempting to
do impersonation - as in Windows impersonation.
Given that your CSLA configuration appears correct, the
problem then must be either in how you are setting up the virtual root, or else
something in your code is causing an attempt to perform Windows
impersonation.
Rocky
madsgonzo@hotmail.com replied on Friday, June 30, 2006
Aragh - found the problem: I was missing a logout.?. If I do logout before login it works.
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Security.PTPrincipal.Logout()
End sub
Thanks !
Mads
Copyright (c) Marimer LLC