Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client domain/workgroup in a remote desktop session

Status
Not open for further replies.

markftwain

Technical User
Jul 12, 2006
108
0
0
Hi experts:

I am using my laptop in different offices to run a visual foxpro application via remoteapp in a session under remote desktop on a different host network. I would like to have vfp on the host detect what domain/workgroup I am connecting from so as to correctly set/use the printers of my local workgroup. I need access to more then a single default printer.

Thank you.
 
This is information I found that Olaf posted for a different question but it might help with your problem.


OlafDoschke (Programmer) 1 Aug 09 12:35

Win32 API functions are case sensitive, so either you DECLARE GetAdaptersInfo ... AS GETADAPTERSINFO or you use it as it is.

It lists all NICs and IP-Adresses. see for a list of informations within a Win32_NetworkAdapterConfiguration.

CODE

Local loWMIService, lcQuery, loNetworkAdapterConfigurations, loNIC, lcIPAddress

lcQuery = "Select * from Win32_NetworkAdapterConfiguration"
loWMIService = Getobject('winmgmts:\\.\root\cimv2')loNetworkAdapterConfigurations = loWMIService.ExecQuery(lcQuery)
For each loNIC in loNetworkAdapterConfigurations
? loNIC.Caption
If loNIC.IPEnabled
For each lcIPAddress in loNIC.IPAddress
? lcIPAddress
EndFor
EndIf
If !IsNull(loNic.MacAddress)
? "MAC Address:",loNic.MacAddress
Endif
EndFor

I went to Search and keyed in Network Info and found it under "How to get local host info"

Hope it helps
Thanks to Olaf for giving us this info in a prior post.
 
Thank you for your help.
Doing as was suggested gives me:
1. the remote desktop session id
2. the user name
3. the client computer name.

The "client IP address" is actually the ip address written to the rdp script on the client computer. There does not seem a way to add the connectiong workgroup to the rdp script. Since I am crossing several routers on the internet, the local client ip address is (by itself) useless. Any idea on how to use the session id to maybe do a tracert back to the client source computer?

Thanks
 
While I don't have an answer to your specific question, I might have a suggestion that would work for you (albeit somewhat 'kludgy').

You might want to set up multiple Windows logins at the central domain.

Then when you login to the Remote Desktop Windows as RemoteSite_A you can use VFP programming to set default printer to PrinterA

And when you when you login to the Remote Desktop Windows as RemoteSite_B you can use the same VFP programming to set default printer to PrinterB

Code:
  cUserName = SYS(0)
  cUserName = ALLTRIM(SUBSTR(cUserName, AT("#",cUserName) + 1))
  DO CASE
     CASE cUserName = 'RemoteSite_A'
        < do whatever >

     CASE cUserName = 'RemoteSite_B'
        < do whatever >
    
     OTHERWISE
        < do whatever >
  ENDCASE

Yes it is somewhat of a hassle in that you would be responsible to remember each time who you should login as, but it would work in lieu of having the Remote Location identified.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top