Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the client name
Message
From
19/04/2015 05:22:05
 
 
To
19/04/2015 05:06:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01618480
Message ID:
01618692
Views:
30
thx Jos



>>>>>Just as an FYI for anyone interested The solution is incredibly simply and does not require accessing any API. You can retrieve the users computer name under a terminal services session simply using Windows Scripting Host in 2 lines ("doh!"):
>>>>>
>>>>>
>>>>>objShell = CreateObject("WScript.Shell")
>>>>>strClient = objShell.ExpandEnvironmentStrings("%clientname%")
>>>>>? strClient
>>>>>
>>>>>
>>....
>>>OK, thanks. We are using this on our own terminal services servers
>>>
>>>.
>>We also run TS sessions, often under an account name used by a small group. Identyfying the machine at the other end of TS is a step nearer to fix some issues brought on by not setting up group policies ;-)
>>Have you found an easy way to get the loginname of the person manning the machine running the TS session?
>>
>>tia
>>
>
>Thomas
>
>Yes, we do this but note my NB at bottom:
>
>
>
>*    GET THE USER LOGIN NAME
>
>TUSER_LOGIN_NAME = ALLTRIM( SUBSTR( SYS(0), AT( "#", SYS(0) ) + 1 )  )
>   
>*    CREATE AN OBJECT REFERENCE TO THE USER LOGIN ACCOUNT
>
>TRY
>
>    TOBJ_Windows_User = getobject( "WinNT://" + Getenv("USERDOMAIN") + "/" + m.TUSER_LOGIN_NAME + ",User" )
>
>CATCH
>
>    TOBJ_Windows_User = .F.
>
>ENDTRY
> 
>*    GET THE USERS FULL NAME AND DESCRIPTION
>
>IF VARTYPE( TOBJ_Windows_User ) = "O"
>
>     TUSER_FULL_NAME    = TOBJ_Windows_User.FullName    
>     TUSER_DESCRIPTION = TOBJ_Windows_User.Description
>
>ELSE
>
>     TUSER_FULL_NAME    = "?"    
>     TUSER_DESCRIPTION = "?"
>
>ENDIF
>
>
>
>NB: The above is relatively slow (a couple of seconds) and so our code tests to see whether the login full name is empty in our file and only attempts the above if empty. In other words, we run this code only once for a user and then not again.
>
>.
Previous
Reply
Map
View

Click here to load this message in the networking platform