Impersonation throwing exception
-
Any help on this error?? This happens when I run the server with ID_A and try to run the client with ID_B .. this is an attempt to try impersonation System.TypeInitializationException was unhandled Message="The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." Source="mscorlib" TypeName="System.Runtime.Remoting.Identity" StackTrace: Server stack trace: at System.Runtime.Remoting.Identity.RemoveAppNameOrAppGuidIfNecessary(String uri) at System.Runtime.Remoting.IdentityHolder.MakeURIKey(String uri) at System.Runtime.Remoting.IdentityHolder.ResolveIdentity(String URI) at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.Object.FieldGetter(String typeName, String fieldName, Object& val) at ns_application.ns_client.cls_client.Main(String[] args) in D:\Vishwjeet\Study\Remoting_tcp\ConsoleApplication2\client.cs:line 64 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Security.Cryptography.CryptographicException Message="Unknown error \"-2146893801\"." Source="mscorlib" StackTrace: at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv) at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters) at System.Security.Cryptography
-
Any help on this error?? This happens when I run the server with ID_A and try to run the client with ID_B .. this is an attempt to try impersonation System.TypeInitializationException was unhandled Message="The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." Source="mscorlib" TypeName="System.Runtime.Remoting.Identity" StackTrace: Server stack trace: at System.Runtime.Remoting.Identity.RemoveAppNameOrAppGuidIfNecessary(String uri) at System.Runtime.Remoting.IdentityHolder.MakeURIKey(String uri) at System.Runtime.Remoting.IdentityHolder.ResolveIdentity(String URI) at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI) at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at System.Object.FieldGetter(String typeName, String fieldName, Object& val) at ns_application.ns_client.cls_client.Main(String[] args) in D:\Vishwjeet\Study\Remoting_tcp\ConsoleApplication2\client.cs:line 64 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.Security.Cryptography.CryptographicException Message="Unknown error \"-2146893801\"." Source="mscorlib" StackTrace: at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) at System.Security.Cryptography.Utils._AcquireCSP(CspParameters param, SafeProvHandle& hProv) at System.Security.Cryptography.Utils.AcquireProvHandle(CspParameters parameters) at System.Security.Cryptography
Are you using System.Diagonistic.Process classes to implement impersonation? Have you placed this in your web.config
<identity impersonate="true" userName="domain\user" password="password" />
This might help u... http://support.microsoft.com/kb/306158[^] I think the actual problem is CryptographicException when running impersonation. :doh: It is very hard to find the actual problem from this. :(Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Are you using System.Diagonistic.Process classes to implement impersonation? Have you placed this in your web.config
<identity impersonate="true" userName="domain\user" password="password" />
This might help u... http://support.microsoft.com/kb/306158[^] I think the actual problem is CryptographicException when running impersonation. :doh: It is very hard to find the actual problem from this. :(Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
hmmm .. actaully this is happening while im trying remoting .. i can give u the code .. if u wanna see .. i am not able to find any message board for remoting .. so was trying my luck out here
yes why not.. Let me see your code. Is it happening when you are connecting to a computer in LAN.. Is the domain configured correctly.. ? Can you connect the remote machine in lan manually? :confused:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
yes why not.. Let me see your code. Is it happening when you are connecting to a computer in LAN.. Is the domain configured correctly.. ? Can you connect the remote machine in lan manually? :confused:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
I am trying impersonation in remoting .. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). I have created the user account on the machine .. and it runs fine when i use secure channel and turn impersonation off.. I have also checked that when impersonation is off and using secure channel .. it allows only the users that i have created to logon .. otherwise it gives authentication failure. Following is the code : Server: using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Collections; using System.Threading; using System.Security.Principal; namespace ns_application { namespace ns_server { public class cls_server { static void Main(string[] args) { //TcpChannel channel = new TcpChannel(8080); IDictionary props = (IDictionary) new Hashtable(); IPrincipal threadPrincipal; props.Add("port", "8080"); props.Add("secure", "true"); props.Add("impersonate", "true"); props.Add("protectionLevel", "EncryptAndSign"); //props.Add("username", "Vishwjeet"); //props.Add("password", "pwd"); //props.Add("authorizationModule", "AuthorizeUser"); //BinaryClientFormatterSinkProvider cp = new BinaryClientFormatterSinkProvider(); //BinaryServerFormatterSinkProvider sp = new BinaryServerFormatterSinkProvider(); IChannel chan = new TcpChannel(props,null,null); ChannelServices.RegisterChannel(chan,true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ns_registeruser.cls_registeruser), "ApplicationMain", WellKnownObjectMode.Singleton); threadPrincipal = Thread.CurrentPrincipal; Console.WriteLine(threadPrincipal.Identity.Name); Console.WriteLine(threadPrincipal.Identity.IsAuthenticated); Console.WriteLine(threadPrincipal.Identity.AuthenticationType); Console.WriteLine("Server Started .. "); Console.ReadLine(); } } } } Methods : using System; using System.Runtime.Serialization; using System.Reflection; using System.Data; using System.Threading; using System.Security.Principal; namespace ns_application { namespace ns_registeruser { //[Serializable] public class cls_whereitruns:MarshalByRefObject { private int _IDNo; public int IDNo { get { return _IDNo; } set { _IDNo = value; } } public int FutureofID() { IDNo = IDNo * 5; Console.WriteLine("Calculated future of ID : {0} :::: {1} :::: {2}", IDNo,this.ToString(),AppDomain.CurrentDomain.FriendlyName); return(IDNo); } public cls_wher