[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get network domain

Posted on 2005-05-04
4
Medium Priority
?
719 Views
Last Modified: 2013-12-26
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.
0
Comment
Question by:IUFITS
  • 3
4 Comments
 
LVL 18

Expert Comment

by:diasroshan
ID: 13933199
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
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 13933457
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
0
 
LVL 18

Accepted Solution

by:
diasroshan earned 2000 total points
ID: 13933815
hi,

just missed the username...

here it goes...

OleObject wsh
Integer  li_rc

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


Cheers,
Rosh
0
 
LVL 3

Author Comment

by:IUFITS
ID: 13937489
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question