4.20.2.3. Actions by username

If the client supplies a default username, the parse_connection_name function can be used to modify the username, and the address and port of the destination server.

Example 4.41. Dynamically change username and server address

The following proxy class examines the username sent by the client and modifies the username and the address of the destination server. If the client sends and unknown username, the connection is rejected.

class MyRdpProxy(RdpProxy):
        def parse_connection_name(self, conn_name):
                if (conn_name == "j@svr1"):
                        return ("joe", "1.1.1.1", 3389)
                elif (conn_name == "a@svr1"):
                        return ("Administrator", "1.1.1.1", 3389)
                elif (conn_name == "j@svr2"):
                        return ("joe", "2.2.2.2", 3389)
                elif (conn_name == "a@svr2"):
                        return ("Administrator", "2.2.2.2", 3389)
                return (None)

        def config(self):
                RdpProxy.config(self)