Link to home
Start Free TrialLog in
Avatar of IUFITS
IUFITS

asked on

How to get network domain

I need to know how to get the network domain of the machine the user is logged into.  I'm using a windows API to get the username logged in to the local machine but I need to get the NT network username and domain instead of the local windows account that's logged in (in the case of say, a VPN connection).  We have an issue where all of our users using an application aren't on the same domain and we want the application to check the network domain and kick them out if they're not authenticated to it.  

Right now, I have a Visual Basic program setup using a reference to the windows script host to get the domain in that application.  If there is no better way to do it in PowerBuilder (through API's already included in Windows) or if not... can someone walk me through setting up a reference to the windows script host in PowerBuilder (I'm passing this PowerBuilder information on to ) and the syntax to create the object.  I'm passing this information onto a programmer who has PowerBuilder (I do not).

I've put 500 on this question due to time constraints... Thank you in advance.
Avatar of diasroshan
diasroshan
Flag of Kuwait image

Hi,

can u tell what ur doin with VB... maybe that cud give a decent hint and help us give u a solution in PB...

in the mean time i will look for a solution....

Cheers,
Rosh
hi,

try..


Here how you get the network username using the Windows Scripting Host : OleObject wsh
Integer  li_rc

wsh = CREATE OleObject
li_rc = wsh.ConnectToNewObject( "WScript.Network" )
IF li_rc = 0 THEN
 MessageBox( "Domain", String( wsh.UserDomain ) )
END IF

 
Cheers,
Rosh
ASKER CERTIFIED SOLUTION
Avatar of diasroshan
diasroshan
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IUFITS
IUFITS

ASKER

I'm going to try this then I'll accept.  It looks like it's gonna work though.  Thanks Rosh.

I maybe posting another question for another 500 due to the way the scripting host pulls back the domain (it always pulls back the local login and not an overlaying VPN domain.. and if they login to our domain we need to allow them access to the program).

Unfortunatley I haven't found a clear cut way in any language to get the overlaying VPN domain.