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. C#
  4. Impersonation with IPCChannel

Impersonation with IPCChannel

Scheduled Pinned Locked Moved C#
sysadmincsharpjsonhelpquestion
3 Posts 2 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.
  • A Offline
    A Offline
    alex1205
    wrote on last edited by
    #1

    Hi, I am trying to connect to IPCChannel using an impersonated user and had encountered an Access Denied exception. Have anyone encountered this? Please help. Please see some code snippets below: Server: BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; System.Collections.IDictionary props = new System.Collections.Hashtable(); props["portName"] = "TestRemoteObject"; props["name"] = "TestRemoteObject"; props["authorizedGroup"] = "Everyone"; props["impersonate"] = true; props["secure"] = true; serverChannel = new IpcServerChannel(props, serverProvider); ChannelServices.RegisterChannel(serverChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject), "TestRemoteObject", WellKnownObjectMode.Singleton); Client: BinaryClientFormatterSinkProvider clientSink = new BinaryClientFormatterSinkProvider(); System.Collections.IDictionary clientProps = new System.Collections.Hashtable(); clientProps["secure"] = true; clientProps["tokenImpersonationLevel"] = TokenImpersonationLevel.Delegation; IpcClientChannel clientChannel = new IpcClientChannel(clientProps, clientSink); ChannelServices.RegisterChannel(clientChannel, true); // Impersonate user to use Administrator IntPtr token; bool result = LogonUser( "Administrator", "MyMachine", "MyPassword", LogonTypes.Network, LogonProviders.Default, out token); if (result) { WindowsIdentity identity = new WindowsIdentity(token); using (WindowsImpersonationContext imp = identity.Impersonate()) { try { RemoteObject remote = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "ipc://TestRemoteObject/TestRemoteObject"); message = remote.Echo("Test"); } catch (Exception exc) { message = exc.ToString(); } imp.Undo(); }

    L 1 Reply Last reply
    0
    • A alex1205

      Hi, I am trying to connect to IPCChannel using an impersonated user and had encountered an Access Denied exception. Have anyone encountered this? Please help. Please see some code snippets below: Server: BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; System.Collections.IDictionary props = new System.Collections.Hashtable(); props["portName"] = "TestRemoteObject"; props["name"] = "TestRemoteObject"; props["authorizedGroup"] = "Everyone"; props["impersonate"] = true; props["secure"] = true; serverChannel = new IpcServerChannel(props, serverProvider); ChannelServices.RegisterChannel(serverChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject), "TestRemoteObject", WellKnownObjectMode.Singleton); Client: BinaryClientFormatterSinkProvider clientSink = new BinaryClientFormatterSinkProvider(); System.Collections.IDictionary clientProps = new System.Collections.Hashtable(); clientProps["secure"] = true; clientProps["tokenImpersonationLevel"] = TokenImpersonationLevel.Delegation; IpcClientChannel clientChannel = new IpcClientChannel(clientProps, clientSink); ChannelServices.RegisterChannel(clientChannel, true); // Impersonate user to use Administrator IntPtr token; bool result = LogonUser( "Administrator", "MyMachine", "MyPassword", LogonTypes.Network, LogonProviders.Default, out token); if (result) { WindowsIdentity identity = new WindowsIdentity(token); using (WindowsImpersonationContext imp = identity.Impersonate()) { try { RemoteObject remote = (RemoteObject)Activator.GetObject(typeof(RemoteObject), "ipc://TestRemoteObject/TestRemoteObject"); message = remote.Echo("Test"); } catch (Exception exc) { message = exc.ToString(); } imp.Undo(); }

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      You are running the server and client on the same machine, right?

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 4a out now (29 May 2008)

      A 1 Reply Last reply
      0
      • L leppie

        You are running the server and client on the same machine, right?

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 4a out now (29 May 2008)

        A Offline
        A Offline
        alex1205
        wrote on last edited by
        #3

        Yes. I was wondering why it doesn't allow me to instantiate a remoting object, when I'm running on an impersonated account.

        SDE

        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