Search code examples
.netsecurityremotingimpersonation

how do i impersonate a windows authenticated web user over a .net remoting call?


I have an web application that uses windows integrated security. I also have a windows service that runs as local system. The web application uses .NET remoting to execute a method on the serivce through tcpip channel. Is there a way, on .NET 2.0, to pass the windows identity to the service?


Solution

  • Per MSDN documentation, configure the client and server app.config files.

    Server:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.runtime.remoting>
            <application>
                <channels>
                  <channel ref="tcp" secure="true" impersonate="true" />
                 </channels>
            </application>
        </system.runtime.remoting>
    </configuration>
    

    Client:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.runtime.remoting>
            <application>
                <channels>
                  <channel ref="tcp" secure="true" tokenImpersonationLevel="impersonation"/>
                 </channels>
            </application>
        </system.runtime.remoting>
    </configuration>
    

    Notice that the attribute is called impersonate for the server but tokenImpersonationLevel for the client.

    See: http://msdn.microsoft.com/en-us/library/59hafwyt(VS.85).aspx