Alaska Software Inc. - Network Name
Username: Password:
AuthorTopic: Network Name
Chris PalmerNetwork Name
on Wed, 21 Dec 2016 14:33:02 +0000
Hello all

We currently use NetName() to identify the unique name of each PC on any 
network
On an RDS server, all names called from NetName() are the same - it seems to 
be the name of the server instead of the user ( I'm not a network engineer 
!!!! )

Can somebody please tell me another function to call the users network name 
that's individual and unique to each user

Thanks for any help
Chris
Matej JuracRe: Network Name
on Wed, 21 Dec 2016 15:49:03 +0100
RDP server is always single machine, except for load balanced terminal servers
(MS and Citrix).

this:

cUserName = GetEnv("username")

will get you local username from windows OS, part of "SET" environment
variables. This should corespond to username as defined on RDP server machine,
not physical machine user connects via RDP.


"Chris Palmer" <chris@towerlotteries.com> wrote in message
news:7c459b88$75299c95$29ea04@news.alaska-software.com...
>Hello all
>
>We currently use NetName() to identify the unique name of each PC on any 
>network
>On an RDS server, all names called from NetName() are the same - it seems to 
>be the name of the server instead of the user ( I'm not a network engineer 
>!!!! )
>
>Can somebody please tell me another function to call the users network name 
>that's individual and unique to each user
>
>Thanks for any help
>Chris
Andreas Gehrs-Pahl
Re: Network Name
on Wed, 21 Dec 2016 14:13:59 -0500
Chris,

>We currently use NetName() to identify the unique name of each PC on any 
>network

NetName() doesn't exist in Xbase++, so I assume you either use Clipper or 
an Xbase++ add-on product, or maybe a user-defined function?

>Can somebody please tell me another function to call the users network name 
>that's individual and unique to each user

To determine the workstation's Computer Name or the current User's Windows 
Login Name with (basic) Xbase++, you can use the following:

#include "DLL.ch"

#define NULL_CHAR   chr(0)

Function Get_Computer_Name()
LOCAL nNameLen  := 255
LOCAL cCompName := Space(nNameLen + 1)
   if DllCall("Kernel32.dll", DLL_STDCALL, "GetComputerNameA", ;
              @cCompName, @nNameLen) == 0
      return ('')
   endif
return (StrTran(alltrim(left(cCompName, nNameLen)), NULL_CHAR, ''))

Function Get_Windows_User_Name()
LOCAL nNameLen  := 255
LOCAL cUserName := Space(nNameLen + 1)
   if DllCall("AdvAPI32.dll", DLL_STDCALL, "GetUserNameA", 
              @cUserName, @nNameLen) == 0
      return ('')
   endif
return (StrTran(alltrim(left(cUserName, nNameLen)), NULL_CHAR, ''))

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Pascal BoivinRe: Network Name
on Wed, 21 Dec 2016 20:41:35 +0100
Just to go a bit further than the others already said:

cComputerName = GetEnv("COMPUTERNAME")
cUserName = GetEnv("Username")
cDomain = GetEnv("UserDomain")
cSession = GetEnv("SessionName")

IF UPPER(LEFT(cSession,3)) == "RDP"
  //We are in a remote session on cComputerName, cUserName is connected
from cClientName
  cClientName = GetEnv("CLIENTNAME")
ENDIF
Chris PalmerRe: Network Name
on Thu, 22 Dec 2016 10:05:08 +0000
Brilliant
Thanks to all of you

Chris


"Pascal Boivin" wrote in message 
news:xn0kf0ansfc3ap000@news.alaska-software.com...

Just to go a bit further than the others already said:

cComputerName = GetEnv("COMPUTERNAME")
cUserName = GetEnv("Username")
cDomain = GetEnv("UserDomain")
cSession = GetEnv("SessionName")

IF UPPER(LEFT(cSession,3)) == "RDP"
  //We are in a remote session on cComputerName, cUserName is connected
from cClientName
  cClientName = GetEnv("CLIENTNAME")
ENDIF
Wolfgang CiriackRe: Network Name
on Thu, 22 Dec 2016 15:26:01 +0100
Am 21.12.2016 um 20:41 schrieb Pascal Boivin:
> Just to go a bit further than the others already said:
>
> cComputerName = GetEnv("COMPUTERNAME")
> cUserName = GetEnv("Username")
> cDomain = GetEnv("UserDomain")
> cSession = GetEnv("SessionName")
>
> IF UPPER(LEFT(cSession,3)) == "RDP"
>    //We are in a remote session on cComputerName, cUserName is connected
> from cClientName
>    cClientName = GetEnv("CLIENTNAME")
> ENDIF
>
Be careful, a romote session can have another session name than "RDP". 
AFAIK the administrator of the server can set this name.
Pascal BoivinRe: Network Name
on Fri, 23 Dec 2016 15:53:34 +0100
Another way would be to check if !Empty .AND. != "Console"