Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Error when trying impersonation

Error when trying impersonation

Scheduled Pinned Locked Moved WCF and WF
securityhelpsharepointsysadminjson
3 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vishwjeet
    wrote on last edited by
    #1

    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

    V 2 Replies Last reply
    0
    • V vishwjeet

      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

      V Offline
      V Offline
      vishwjeet
      wrote on last edited by
      #2

      The code is working now .. but it works only for the account using which i have logged on onto the machine .. it says "The type initializer for 'System.Runtime.Remoting.Identity' threw an exception." when I give any other valid userid password

      1 Reply Last reply
      0
      • V vishwjeet

        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

        V Offline
        V Offline
        vishwjeet
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups