Jump to content

Check if network user is logged on.


Recommended Posts

I have a GUI that I have been working on and before finishing it, I need a way to tell if a user is logged on to their system. -moving the mouse, using the keyboard, anything . . .

The GUI has a list of users and can send messages via net send to any of those users. Each will have the GUI. I need a way to display on the GUI if other users are logged on to their system.

It will have to be intranet based. Sending stats to a webserver is not an option because of privacy concerns.

I am open to any ideas or tips on how to do this. Other post refs are very welcome!

Thanks :whistle:

Link to comment
Share on other sites

I have a GUI that I have been working on and before finishing it, I need a way to tell if a user is logged on to their system. -moving the mouse, using the keyboard, anything . . .

The GUI has a list of users and can send messages via net send to any of those users. Each will have the GUI. I need a way to display on the GUI if other users are logged on to their system.

It will have to be intranet based. Sending stats to a webserver is not an option because of privacy concerns.

I am open to any ideas or tips on how to do this. Other post refs are very welcome!

Thanks :whistle:

This sounds like a GAIM-style chat application that indicates who else is online to talk to. The easiest way to handle that is to have the client on each workstation send status to a central server (on the LAN, not to an external site, as you indicated). The server side can accept "online" status from the client, plus time out the client to "offline" if the client doesn't update its status periodically. So:

1. Server side is running, keeps list of online clients

2. Client comes up and requests online user list from server

3. Server notes that client is online and adds to list

4. Server notes time of last status request from this client

5. Server replies with complete list of clients online

6. Client presents user with list of other clients.

7. Client periodically requests updated list from server

8. Server periodically checks time since last status request from each client and removes from list if timeout

:lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

@all

This will show the logged on user.

#include <date.au3>

$strComputer = "."
 $objWMIService = ObjGet("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

 $colItems = $objWMIService.ExecQuery _
    ("Select * from Win32_NetworkLoginProfile where AuthorizationFlags = 4")

For $objItem in $colItems
    $dtmWMIDate = $objItem.AccountExpires
    $strReturn = WMIDateStringToDate($dtmWMIDate)
    Consolewrite ("Account Expires: " & $strReturn & @CR)
    Consolewrite ("Authorization Flags: " & $objItem.AuthorizationFlags & @CR)
    Consolewrite ("Bad Password Count: " & $objItem.BadPasswordCount & @CR)
    Consolewrite ("Caption: " & $objItem.Caption & @CR)
    Consolewrite ("CodePage: " & $objItem.CodePage & @CR)
    Consolewrite ("Comment: " & $objItem.Comment & @CR)
    Consolewrite ("Country Code: " & $objItem.CountryCode & @CR)
    Consolewrite ("Description: " & $objItem.Description & @CR)
    Consolewrite ("Flags: " & $objItem.Flags & @CR)
    Consolewrite ("Full Name: " & $objItem.FullName & @CR)
    Consolewrite ("Home Directory: " & $objItem.HomeDirectory & @CR)
    Consolewrite ("Home Directory Drive: " & $objItem.HomeDirectoryDrive & @CR)
    $dtmWMIDate = $objItem.LastLogoff
    $strReturn = WMIDateStringToDate($dtmWMIDate)
    Consolewrite ("Last Logoff: " & $strReturn & @CR)
    $dtmWMIDate = $objItem.LastLogon
    $strReturn = WMIDateStringToDate($dtmWMIDate)
    Consolewrite ("Last Logon: " & $strReturn & @CR)
    Consolewrite ("Logon Hours: " & $objItem.LogonHours & @CR)
    Consolewrite ("Logon Server: " & $objItem.LogonServer & @CR)
    Consolewrite ("Maximum Storage: " & $objItem.MaximumStorage & @CR)
    Consolewrite ("Name: " & $objItem.Name & @CR)
    Consolewrite ("Number Of Logons: " & $objItem.NumberOfLogons & @CR)
    Consolewrite ("Password Age: " & $objItem.PasswordAge & @CR)
    $dtmWMIDate = $objItem.PasswordExpires
    $strReturn = WMIDateStringToDate($dtmWMIDate)
    Consolewrite ("Password Expires: " & $strReturn & @CR)
    Consolewrite ("Primary Group ID: " & $objItem.PrimaryGroupId & @CR)
    Consolewrite ("Privileges: " & $objItem.Privileges & @CR)
    Consolewrite ("Profile: " & $objItem.Profile & @CR)
    Consolewrite ("Script Path: " & $objItem.ScriptPath & @CR)
    Consolewrite ("Setting ID: " & $objItem.SettingID & @CR)
    Consolewrite ("Units Per Week: " & $objItem.UnitsPerWeek & @CR)
    Consolewrite ("User Comment: " & $objItem.UserComment & @CR)
    Consolewrite ("User Id: " & $objItem.UserId & @CR)
    Consolewrite ("User Type: " & $objItem.UserType & @CR)
    Consolewrite ("Workstations: " & $objItem.Workstations & @CR)
    Consolewrite ("----------------"& @CR)
Next
 
Func WMIDateStringToDate($dtmWMIDate)
    Local $Return
    If Not $dtmWMIDate ="" Then
  
    Return (StringMid($dtmWMIDate, 5, 2) & "/" & _
            StringMid($dtmWMIDate, 7, 2) & "/" & StringLeft($dtmWMIDate, 4) _
            & " " & StringMid($dtmWMIDate, 9, 2) & ":" & StringMid($dtmWMIDate, 11, 2) & ":" & StringMid($dtmWMIDate,13, 2))

    Return $Return
    Endif
EndFunc

The output can easily be outputted in an HTML file on an Intranet.

regards,

ptrex

Link to comment
Share on other sites

@all

This will show the logged on user.

The output can easily be outputted in an HTML file on an Intranet.

regards,

ptrex

Good stuff, but I think it's overkill for the IM app the OP seems to be implementing. Doesn't look like administrative logging of user details is the point.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This sounds like a GAIM-style chat application that indicates who else is online to talk to. The easiest way to handle that is to have the client on each workstation send status to a central server (on the LAN, not to an external site, as you indicated). The server side can accept "online" status from the client, plus time out the client to "offline" if the client doesn't update its status periodically. So:

1. Server side is running, keeps list of online clients

2. Client comes up and requests online user list from server

3. Server notes that client is online and adds to list

4. Server notes time of last status request from this client

5. Server replies with complete list of clients online

6. Client presents user with list of other clients.

7. Client periodically requests updated list from server

8. Server periodically checks time since last status request from each client and removes from list if timeout

:whistle:

I like the idea of using a file on the lan. Gonna run something by you just to see if you think it would work.

I would like to have a file placed on the lan. A database, or any other easy to work solution where a table exsists with fields:

USERID (PC Logon)

Actual name (Display Name pulled back to GUI)

Two skill fields

one log on time field

one log off time field.

A user would open the GUI

The GUI connects to the file and searches the table for The USERID. -If found, it adds a logon time for the user and pulls all other users with a time X minutes less from now() where Logon is greater than Logoff

If userid Is not found it opens a second input GUI for the record to add to the table.

The GUI would requery the file every x the GUI is open. Before close, the GUI would send Log off time.

Sound like it would work? would this be slow? Thanks for any help!

Edited by Hatcheda
Link to comment
Share on other sites

I like the idea of using a file on the lan. Gonna run something by you just to see if you think it would work.

I would like to have a file placed on the lan. A database, or any other easy to work solution where a table exsists with fields:

USERID (PC Logon)

Actual name (Display Name pulled back to GUI)

Two skill fields

one log on time field

one log off time field.

A user would open the GUI

The GUI connects to the file and searches the table for The USERID. -If found, it adds a logon time for the user and pulls all other users with a time X minutes less from now() where Logon is greater than Logoff

If userid Is not found it opens a second input GUI for the record to add to the table.

The GUI would requery the file every x the GUI is open. Before close, the GUI would send Log off time.

Sound like it would work? would this be slow? Thanks for any help!

The answer depends on how much you want to 'manage' this. If it is only going to be used by authenticated users that have successfully logged on to managed workstations in an AD domain, then just a file in a share is enough. Give authenticated users write perms to the file (maybe an SQLite Data.db) and leave it to your client script on each workstation to behave itself. GUIs and management processes for adding/deleting users are not required. Each client adds itself or updates its own "last seen" time. Each client reads the rest of the user's status from the same place. Each client changes its own status to "offline" when closing.

For a basic IM app that's all you need.

Now, if you are going to start 'managing' things, you have to state clearly what you need. Is this really just to log user activity, track over-long coffee breaks, initiate disciplinary actions, etc.? Then you have to make it secure against user spoofing/tampering/etc. and the answers get long, complicated, and legalistic.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

na, its just gonna be used for help with specific questions. 'you get a question you can't handle' = you see who's logged on and what skill then you im them for help. I wouldn't want to im an empty cube and expect it to whip up a answer very quickly :lmao: As far as the tight logging jiberish, we already have that! but thats another story. :whistle: All passwords and names are pulled down from the domain, so there will be no faking who's who. Plus I will be locking up the source and not giving the path past sup/mrg level. "So whos to say where the file is . . ." -could apply password access and place it in the source code aswell.

I grabbed a bit of Access code earlier. I know nothing about SQL but have been needing to work with it. Do you suppose it woud be easier to work with since all code will be ground up so to speak? does autoit talk SQL easier?

Some good Access code:

http://www.autoitscript.com/forum/index.ph...mp;#entry230946

Edited by Hatcheda
Link to comment
Share on other sites

I don't think an Access file gives you multiple access.

AutoIt has UDF include files for using SQLite, and I think it's you best option, if have a little time to learn something new and very useful. Check out the web site for SQLite to learn more, and check the AutoIt help file for the _SQL* functions to see how it's done.

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't think an Access file gives you multiple access.

AutoIt has UDF include files for using SQLite, and I think it's you best option, if have a little time to learn something new and very useful. Check out the web site for SQLite to learn more, and check the AutoIt help file for the _SQL* functions to see how it's done.

:whistle:

Hey! Thanks for the input! Access does offer multiple access. I am very heavy on excel pulls and pushes from a lan based Access db

I have never played around with SQLite and was thinking from all the posts that it would be easier. Thanks for the link and input. I think I will be learning SQL now! :lmao:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...