Error when trying impersonation
-
Hi.. I am trying impersonation in remoting .. it gives some error. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). Can anyone help me out find what am I doing wrong?? 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
-
Hi.. I am trying impersonation in remoting .. it gives some error. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). Can anyone help me out find what am I doing wrong?? 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
-
Hi.. I am trying impersonation in remoting .. it gives some error. The program runs fine when i turn off impersonation. I am running client and server both on the same machine(VISTA). Can anyone help me out find what am I doing wrong?? 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
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.Utils.get_StaticProvHan