Discussion:
How can I list all the users logged on to a server in my domain at any time?
(too old to reply)
WP
2008-06-03 03:19:43 UTC
Permalink
Stefan Wuebbe
2008-06-03 08:01:33 UTC
Permalink
How can I list all the users logged on to a server in my domain at any time?
You can perhaps get it via WMI, try to google for "scriptomatic" and related.
Quoted from a posting by Rick Bean:
I did some exploring a while back, and the following code exposes all the user
properties I could find, but I believe there are more. If you can add to my
list, please do, may be we can document more.

strDomain = "DOMAIN"
Public PrimDomainContr
Create cursor ADnames (username c(30),fullname c(80),descript c(80),Class
c(50),accdisable l,;
acclocked l,profile c(30),loginscrpt c(50),Homedir c(30))
PrimDomainContr = Getobject("WinNT://" + strDomain)
SET STEP on
For Each User In PrimDomainContr
If User.Class = 'User'

Insert Into ADnames
(username,fullname,descript,Class,accdisable,acclocked,profile,;
loginscrpt,Homedir) Values
(User.Name,user.fullname,User.description,User.Class,User.AccountDisabled,;
User.IsAccountLocked,User.Profile,User.loginscript,User.Homedirectory)
Endif
Next
Browse Norm

Rick
hth
-Stefan
WP
2008-06-03 12:06:13 UTC
Permalink
Thanks Rick, this is nice for getting the properties of the users of the
domain, but I would like to see if the user has logged on to the server, so
I would like to get back something similar to "net session". I have to keep
track of the number of users logged on at any moment, and record it every 15
minutes.

Walter
Post by Stefan Wuebbe
How can I list all the users logged on to a server in my domain at any time?
You can perhaps get it via WMI, try to google for "scriptomatic" and related.
I did some exploring a while back, and the following code exposes all the user
properties I could find, but I believe there are more. If you can add to my
list, please do, may be we can document more.
strDomain = "DOMAIN"
Public PrimDomainContr
Create cursor ADnames (username c(30),fullname c(80),descript c(80),Class
c(50),accdisable l,;
acclocked l,profile c(30),loginscrpt c(50),Homedir c(30))
PrimDomainContr = Getobject("WinNT://" + strDomain)
SET STEP on
For Each User In PrimDomainContr
If User.Class = 'User'
Insert Into ADnames
(username,fullname,descript,Class,accdisable,acclocked,profile,;
loginscrpt,Homedir) Values
(User.Name,user.fullname,User.description,User.Class,User.AccountDisabled,;
User.IsAccountLocked,User.Profile,User.loginscript,User.Homedirectory)
Endif
Next
Browse Norm
Rick
hth
-Stefan
Olaf Doschke
2008-06-03 15:23:45 UTC
Permalink
The User object created by the script may also have
LastLogin and LastLogOff properties.
If LastLogIn>LastLagoff the user will be logged in.

But if you have not only one DC, that's not giving you
the real last login/off.

See here for examples and the pros and cons. If you
are in a large network, you may need to query many
domain controllers to really get the lastlogon.

http://boards.cramsession.com/boards/vbms.asp?d=744261&pvm=False

http://www.rlmueller.net/Last%20Logon.htm

What's valid for the lastlogon should also be valid for the
lastlogoff.

Bye, Olaf.
WP
2008-06-06 21:49:11 UTC
Permalink
The problem is: the lastlogoff field is always zero, so it is not useful.
Post by Olaf Doschke
The User object created by the script may also have
LastLogin and LastLogOff properties.
If LastLogIn>LastLagoff the user will be logged in.
But if you have not only one DC, that's not giving you
the real last login/off.
See here for examples and the pros and cons. If you
are in a large network, you may need to query many
domain controllers to really get the lastlogon.
http://boards.cramsession.com/boards/vbms.asp?d=744261&pvm=False
http://www.rlmueller.net/Last%20Logon.htm
What's valid for the lastlogon should also be valid for the
lastlogoff.
Bye, Olaf.
Kevin Spaeth
2011-02-02 03:13:55 UTC
Permalink
Lol, isn't it nice how they put a last login field, but don't populate it. You could use a third party app like Active Directory Network Manager (http://logicdevelopment.net/adnm/)
Post by Stefan Wuebbe
You can perhaps get it via WMI, try to google for "scriptomatic" and related.
I did some exploring a while back, and the following code exposes all the user
properties I could find, but I believe there are more. If you can add to my
list, please do, may be we can document more.
strDomain = "DOMAIN"
Public PrimDomainContr
Create cursor ADnames (username c(30),fullname c(80),descript c(80),Class
c(50),accdisable l,;
acclocked l,profile c(30),loginscrpt c(50),Homedir c(30))
PrimDomainContr = Getobject("WinNT://" + strDomain)
SET STEP on
For Each User In PrimDomainContr
If User.Class = 'User'
Insert Into ADnames
(username,fullname,descript,Class,accdisable,acclocked,profile,;
loginscrpt,Homedir) Values
(User.Name,user.fullname,User.description,User.Class,User.AccountDisabled,;
User.IsAccountLocked,User.Profile,User.loginscript,User.Homedirectory)
Endif
Next
Browse Norm
Rick
hth
-Stefan
Post by WP
Thanks Rick, this is nice for getting the properties of the users of the
domain, but I would like to see if the user has logged on to the server, so
I would like to get back something similar to "net session". I have to keep
track of the number of users logged on at any moment, and record it every 15
minutes.
Walter
Post by Olaf Doschke
The User object created by the script may also have
LastLogin and LastLogOff properties.
If LastLogIn>LastLagoff the user will be logged in.
But if you have not only one DC, that's not giving you
the real last login/off.
See here for examples and the pros and cons. If you
are in a large network, you may need to query many
domain controllers to really get the lastlogon.
http://boards.cramsession.com/boards/vbms.asp?d=744261&pvm=False
http://www.rlmueller.net/Last%20Logon.htm
What's valid for the lastlogon should also be valid for the
lastlogoff.
Bye, Olaf.
Post by WP
The problem is: the lastlogoff field is always zero, so it is not useful.
Submitted via EggHeadCafe
Excel Generate High Quality RoadMaps
http://www.eggheadcafe.com/tutorials/aspnet/3310004f-e1ae-45a7-9bea-7b2b970d1230/excel-generate-high-quality-roadmaps.aspx
Continue reading on narkive:
Loading...