I've come across a showstopper in my magnificent task to create a printer GPO which maps printers inside the TS session based on the RDP client address - the address isn't known when using a gateway server :(
Right-click + status on a session via RD gateway:
Same thing on a session NOT going through RD gateway:
Does anyone know if this is possible to get around? Are there perhaps some kind of undocumented registry change I can do on the gateway server to pass this information along?
Looks like this isn't possible. I'm going to file a feature request with Microsoft.
Since the TS gateway is effectively a proxy, why don't you query the proxy's logs? Filtering for the last event 303 from Remote Desktop Gateway by the user in question should supply you with the IP. I am not aware of any "X-Forwarded-For"-style header in RDP.
I saw this, I don't know if it helps, but did want to pass it along just incase.
http://www.virtualizationadmin.com/kbase/VirtualizationTips/DesktopVirtualization/MicrosoftVirtualDesktopInfrastructureTips/InstallationDeployment/GPOpreferenceswithTerminalSessionItemLevelTargeting.html
Perhaps you could create a logon script that maps the printer based on the RDP connection? First create an "iplist.txt" file that contains the ip addresses and departments that you want to map the printer for:
Place the iplist.txt file in a directory that the person logging on will have read access to. From there you can use this batch file to map the printer:
You also want to make sure that logfile.txt gets written to a location that the user logging on will have write access to.
It may not be the reg hack your looking for, but it could work as an alternative....