Solved

Sensing NT network connection

Posted on 1999-01-05
2
156 Views
Last Modified: 2010-05-03
Is there a way in VB that I can test to determine whether or not the host system is currently logged onto a network?  (Specifically, NT).
0
Comment
Question by:harrrj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1454078
Take a look at this site. It contains kinds of code about  NT including what you want

http://www.netfokus.dk/vbadmincode/codevb.html
0
 
LVL 1

Accepted Solution

by:
NoCheese earned 100 total points
ID: 1454079
Keep in mind that an NT workstation is always logged onto a network, even when it is standalone, it is part of it's own local domain.

If you want to see if a user is logged on to the local machine or an external network such as a domain, is to compare the environment variable %COMPUTERNAME% against %USERDOMAIN%.  If they are the same, the user is logged in with a local account.  If they are different they are logged in to an external domain.

That is just half of the puzzle.  Once you have determined that the user is logged into an external domain, you need to find out if the user was actually validated, or logged in with cached credentials because they are currently disconnected.  Retreive the variable %LOGONSERVER%, append "\NETLOGON" to the end of it, and use that as the server path in the WNetGetUser API.  If the return value is NON "0", then the user is disconeccted.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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