• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2085
  • Last Modified:

check if user currently logon onto domain

I am looking for the script that check if the user is currently logging onto domain or not. Please help me out.
0
2LL
Asked:
2LL
  • 2
  • 2
1 Solution
 
2LLAuthor Commented:
Hi Briancassin,
Sorry I did not make clear to you. I have user name, I want to check if that user are currently logon into the domain?
0
 
jkrCommented:
Check the content of %USERDOMAIN% - if that is not the local host name (i.e. not equivalent to %COMPUTERNAME%), it is the domain's name.
0
 
2LLAuthor Commented:
jkr,
I am new to VBScript can you explain a little more on it please. Here is the script that briancassin give to me via link above. What do I need to modify?

Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
Wscript.Echo objComputer.UserName & " is logged on"
Next
0
 
jkrCommented:
Hm, that script does completely different things. You could
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Environment Where Name = 'USERDOMAIN'")
 
For Each objItem in colItems
    Set UserDomain = objItem.Name
Next

Open in new window

0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now