473,804 Members | 3,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching events when users logon/logoff

Hi all,

I'm implementing a windows service (running with local system account) which
has to do some tasks when users logon/logoff. How can the service register
to those logon/logoff-events? I'm using .NET 1.1 and C# and the service will
be installed on machines with os >= W2K.

If you have any solution or hint tracking down this problem please let me
know!

Regards
Raimund
Dec 1 '05 #1
2 3223
WMI (in System.Manageme nt namespace) offers a large number of various event
providers for this type of requirement. Hint: not for the faint of heart,
will require some study.
Good Luck!
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Raimund Taschler" wrote:
Hi all,

I'm implementing a windows service (running with local system account) which
has to do some tasks when users logon/logoff. How can the service register
to those logon/logoff-events? I'm using .NET 1.1 and C# and the service will
be installed on machines with os >= W2K.

If you have any solution or hint tracking down this problem please let me
know!

Regards
Raimund

Dec 1 '05 #2
Hi
In order to receive such notifications you need to register windows handler
(HWND) with WTSRegisterSess ionNotification (see MSDN for more info)

Unfortunately there is no managed solution for this and you neet to use
PInvoke.

Services don't provide UI, but you can create a hidden form that will
receive the notfication. I believe this won't be a security issue as long as
you don't show it.
HTH
Stoitcho Goutsev (100) [C# MVP]

"Raimund Taschler" <ta*@adv.magwie n.gv.at> wrote in message
news:11******** ******@proxy.di enste.wien.at.. .
Hi all,

I'm implementing a windows service (running with local system account)
which has to do some tasks when users logon/logoff. How can the service
register to those logon/logoff-events? I'm using .NET 1.1 and C# and the
service will be installed on machines with os >= W2K.

If you have any solution or hint tracking down this problem please let me
know!

Regards
Raimund

Dec 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1781
by: Porky | last post by:
Scenario: login/logoff scripts that kick username, times, and dates out to a CSV file. I have a linked table in access pointing to that CSV file. Users typically log in and log out twice a day (they are required by company policy to log out when they go to lunch). Problem: I am trying to figure out a way to check when they logged in first thing in the morning. Certain performance bonuses are based on whether or not they logged into...
1
7675
by: MCzajk | last post by:
Is there a way to intercept event, when user logs on/off to the system inside windows service? Thx for any tip, MCzajk
7
8195
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being shut down or restarted. At all other times, the service runs just fine. I need to either detect a logon/logoff event OR check somehow as to whether there is currently a valid logged on user. The closest I have found is ManagementEventWatcher...
2
2264
by: NWx | last post by:
Hi, I have the following question: I have an app that uses user login/logout to identify users When user logon, I register logon time in a session variable When user logoff using the logout link, I also register logoff time and update accordingly the logging history table. However user can simply close the browser without logoff, so his session was closed.
6
1336
by: Randall Parker | last post by:
Suppose the first URL a visitor visits is Logon.aspx. There's not an original page to return the user to. So how can I detect whether to send the user to the original page he tried to visit versus send him to a default page? I'm looking at this in the MS doc: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebSecurityFormsAuthenticationClassTopic.asp void LoginBtn_Click(Object sender, EventArgs...
5
1777
by: Paal Berggreen | last post by:
I am involved with development of a Portal solution using ASP.NET 2.0 and WebParts. The WebParts framework use the default personalization providers, and the personalization data thus ends up in the aspnetdb database (which we have placed on a proper SQL Server, not SQL Server Express). Everything works like a charm, with the following exception: New users in the system have to press links or buttons twice upon their first logon to...
0
2526
by: gewe | last post by:
Can anyone tell me what is wrong with the following code? The code has to watch for logon/logoff events: public void StartListenLogon() { EventHandler handler = new EventHandler(); WqlEventQuery query = new WqlEventQuery(); query.EventClassName = "__InstanceOperationEvent"; query.WithinInterval = new TimeSpan(0, 0, 3);
2
2219
by: =?Utf-8?B?SVNE?= | last post by:
Question: How do I refresh on the local computer the users AD( LDAP ) credentials without having them re-log our re-boot their system? Scenario: Users A is denied access to folder Z. Admin on DC grants User A group membership to a group that has access to folder Z. User A ( without having to log out or reboot ) access folder Z.
2
1863
by: Dan2kx | last post by:
Function LogonLog(OnOff As String) Dim rst As DAO.Recordset If OnOff = "On" Then Set rst = CurrentDb.OpenRecordset("tblLogonLog", dbOpenDynaset, dbAppendOnly) rst.AddNew rst!StaffID = LogStaffID rst!Logon = Now() rst.Update ElseIf OnOff = "Off" Then Set rst = CurrentDb.OpenRecordset("SELECT Max(tblLogonLog.LID) AS LID FROM tblLogonLog HAVING (((tblLogonLog.StaffID)=1) AND ((tblLogonLog.LogOff)...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.