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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
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.
2LLAuthor Commented:
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"
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

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.