Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Does any one know how to listen for the login event of the active directory in c#
Posted
Comments
johannesnestler 26-Feb-14 9:02am    
good question...
Kornfeld Eliyahu Peter 26-Feb-14 9:38am    
Are you talking about this - http://msdn.microsoft.com/en-us/library/system.diagnostics.tracing(v=vs.110).aspx?

1 solution

There is no "event", as in code events, and no notification to subscribe to.

You could do this by monitoring the Security EventLog for eventId 4624 (Logon), but your code would have to be monitoring the logs of ALL the domain controllers servicing the domain in question. You'll also need admin permissions to the servers to do it.
 
Share this answer
 
Comments
mrDivan 27-Feb-14 8:19am    
Thank you will one be able to see username

Kind regards :)
Dave Kreskowiak 27-Feb-14 9:05am    
Have you looked I at one of those events in EventVwr? Yes, you can see it.
mrDivan 27-Feb-14 8:53am    
Good day Dave

Here is my scenario: when the user logs in I want to immediately change his password email his new password to him update his password and expiry date in active directory. I have learned how to change the password in ad Im just looking for a way to detect the login

I know my explanation is basic but I am just trying to find out if it is possible

Kind regards
Dave Kreskowiak 27-Feb-14 9:07am    
Sounds like a stupid idea.

What if the user locks the workstation before seeing the new password? The user will not be able to unlock the workstation without a support call to you.

Also, a "logon" in ActiveDirectory can happen multiple times and at any time, even after a user is logged onto their machine. A logon event happens upon access of resources, not neccessarily when the user picks start hitting the keyboard and mouse.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900