Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# logon and logoff events are create when checking anything on the network

Posted on 2013-12-10
7
Medium Priority
?
404 Views
Last Modified: 2013-12-14
I've create a simple C# service that is checking the existence of a shared network path (on a domain) every 20 seconds.

the service is running using an account with Domain Admin rights.

My problem is that every 20 seconds a logon event is created (4624) and after 12 seconds a logoff event is created (4634).

Why? Is there a way to prevent that? I need the service to check every 20 seconds. I have no problem that it will logon once. But why it logs off every 12 seconds and logged on again?

Thanks
0
Comment
Question by:or1969
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 39712646
Are you looking for changes to the path?  Is it on a Windows system?  If yes, are you using the FileSystemWatcher class?
0
 

Author Comment

by:or1969
ID: 39713285
The same happens on the Microsoft OS's I've tested (XP and 7) checking if a directory or file exist on the connected network.

C# line is : Directory.Exist(@\\<MACHINENAME>\<SHARENAME>)
0
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 39713398
You didn't answer my question.  Are you using the FileSystemWatcher class in a service?  It doesn't sound like you are.  The FileSystemWatcher class is built to do what you are doing.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:or1969
ID: 39713442
I using System.IO
Any of the classes used for connecting to the network will will create a logon event.

After additional testing, I've found that a logoff event is created after exactly 12 seconds.

When changing the timer to 5 seconds, the logon event is created once and there are no logoff events. I guess this keeps the session alive.

Now I'm thinking to create a separate thread timer that will check if a directory in the network exist every 5 seconds (keepalive).

May main concern, will it have any impact on communication of the DC?
0
 
LVL 51

Accepted Solution

by:
Ted Bouskill earned 2000 total points
ID: 39717332
I'd HIGHLY recommend you try the FileSystemWatcher class.  it was designed for what you are doing and rather than recreate it yourself you might have more luck with it.

Also, are you running the service using the account that has credentials to access the share or are you authenticating in your code?  What account is the service running as?
0
 

Author Comment

by:or1969
ID: 39717366
The service is running with a user account with domain admin rights and have access to the network share.

Thanks for the suggestion to use the FileSystemWatcher Class. I'll have time to test it tomorrow.

Thanks.
0
 
LVL 51

Expert Comment

by:Ted Bouskill
ID: 39717433
Not sure why the credentials aren't cached then.  Hopefully the FileSystemWatcher might fix it.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question