473,474 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Windows Service Account

I'm hoping someone can give me a little guidance. I have written a
simple Windows Service that goes out and scrapes a few web pages and
updates some data in an access database. The service works correctly
in the IDE and trying to be a good citizen I set it to run as "Local
Service" when I install it.

However once installed it fails silently. My log eventlog message
saying the the DB was updated successfully is written, however the
actual write to the database doesn't happen. There does not seem to
be an error or exception that I can catch, it just doesn't write.

Once I change the service to run as "Local System" it works
correctly. So my question is should I really avoid using "Local
System". I have read the articles explaing he dangers, yet I see lots
of services running as it on my system. Maybe its more like a
guidance "Do so if you can, but if not don't worry too much about it?"
Is there another option? Is there a better way to know where the
problem with the "Local Service" account exists? Like I said when I
debug it in the IDE it works correctly, but at that point it is
running as my user account (which apparently has all the rights it
needs).

Should I just create another user account and play with the permission
until I find the right ones. This service goes out to client
locations so I hate to make them do too much manual work in creating
an account (as some clients I doubt would even know how to do it),
etc?

Thanks,

Matt
Jul 31 '08 #1
3 1866

I'm guessing your db isn't configured to allow permissions from the (being
used) user.

2 suggestions:
Switch to sql authentication.

Figure out ( and give permissions ) to the correct user for your db.
Here is some crappy code to figure out (so you can log it) the user.
You're thinking "I know who the user is", but sometimes its good to do it
while in the code.

Go to Control Panel / Users and you can see a list of "built in" users that
a windows machine has.

private string FindIIdentity()

{

try

{

string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity.GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environment.MachineName;

}

catch (Exception ex)

{

}

return returnValue;

}

catch (Exception ex)

{

return "Error Finding Identity";

}

}


"Matt Lowrance" <ma*************@gmail.comwrote in message
news:87**********************************@a1g2000h sb.googlegroups.com...
I'm hoping someone can give me a little guidance. I have written a
simple Windows Service that goes out and scrapes a few web pages and
updates some data in an access database. The service works correctly
in the IDE and trying to be a good citizen I set it to run as "Local
Service" when I install it.

However once installed it fails silently. My log eventlog message
saying the the DB was updated successfully is written, however the
actual write to the database doesn't happen. There does not seem to
be an error or exception that I can catch, it just doesn't write.

Once I change the service to run as "Local System" it works
correctly. So my question is should I really avoid using "Local
System". I have read the articles explaing he dangers, yet I see lots
of services running as it on my system. Maybe its more like a
guidance "Do so if you can, but if not don't worry too much about it?"
Is there another option? Is there a better way to know where the
problem with the "Local Service" account exists? Like I said when I
debug it in the IDE it works correctly, but at that point it is
running as my user account (which apparently has all the rights it
needs).

Should I just create another user account and play with the permission
until I find the right ones. This service goes out to client
locations so I hate to make them do too much manual work in creating
an account (as some clients I doubt would even know how to do it),
etc?

Thanks,

Matt


Jul 31 '08 #2
Read the OP carefully:

1. The OP does not need to find which user account is running the Windows
service. He has said that it work when using "Local System" account, but not
when using "Local Servic" account.
2. He does not use SQL Server, hence not point to "switch to sql
authentication"

To the OP:

Since you use Jet database (Access database), the user account that runs the
application and accesses data in it must have read/write permission to the
folder where the *.mdb file is in. Local System account has mighty power to
access to almost everywhere of the computer, hence it works. Local Service
account, on the other hand, has very limited access to computer resources by
default, you need to explicitly assign permissions to this account to use
resources on the computer. That is, when you place a program to a computer
running as services, you should start with a most restricted user account
and only assign access permissions as needed. In your case, it is good
choice to use Local Service account, but you need to explicitly allow this
account to read/write to the floder where *.mdb sits. Of course you can
choose other user account to run the windows service as long as the account
has sufficient access permissions.

"sloan" <sl***@ipass.netwrote in message
news:OH**************@TK2MSFTNGP05.phx.gbl...
>
I'm guessing your db isn't configured to allow permissions from the (being
used) user.

2 suggestions:
Switch to sql authentication.

Figure out ( and give permissions ) to the correct user for your db.
Here is some crappy code to figure out (so you can log it) the user.
You're thinking "I know who the user is", but sometimes its good to do it
while in the code.

Go to Control Panel / Users and you can see a list of "built in" users
that
a windows machine has.

private string FindIIdentity()

{

try

{

string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity.GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environment.MachineName;

}

catch (Exception ex)

{

}

return returnValue;

}

catch (Exception ex)

{

return "Error Finding Identity";

}

}


"Matt Lowrance" <ma*************@gmail.comwrote in message
news:87**********************************@a1g2000h sb.googlegroups.com...
>I'm hoping someone can give me a little guidance. I have written a
simple Windows Service that goes out and scrapes a few web pages and
updates some data in an access database. The service works correctly
in the IDE and trying to be a good citizen I set it to run as "Local
Service" when I install it.

However once installed it fails silently. My log eventlog message
saying the the DB was updated successfully is written, however the
actual write to the database doesn't happen. There does not seem to
be an error or exception that I can catch, it just doesn't write.

Once I change the service to run as "Local System" it works
correctly. So my question is should I really avoid using "Local
System". I have read the articles explaing he dangers, yet I see lots
of services running as it on my system. Maybe its more like a
guidance "Do so if you can, but if not don't worry too much about it?"
Is there another option? Is there a better way to know where the
problem with the "Local Service" account exists? Like I said when I
debug it in the IDE it works correctly, but at that point it is
running as my user account (which apparently has all the rights it
needs).

Should I just create another user account and play with the permission
until I find the right ones. This service goes out to client
locations so I hate to make them do too much manual work in creating
an account (as some clients I doubt would even know how to do it),
etc?

Thanks,

Matt


Jul 31 '08 #3
Youch.

You got me. I did not see "access" at all til I read closely.

Nix my post. Sorry for the confusion.
Well, you can use the find IIDentity to the user to give folder permissions
to I guess.
But as stated, you already know the user account.

"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
Read the OP carefully:

1. The OP does not need to find which user account is running the Windows
service. He has said that it work when using "Local System" account, but
not when using "Local Servic" account.
2. He does not use SQL Server, hence not point to "switch to sql
authentication"

To the OP:

Since you use Jet database (Access database), the user account that runs
the application and accesses data in it must have read/write permission to
the folder where the *.mdb file is in. Local System account has mighty
power to access to almost everywhere of the computer, hence it works.
Local Service account, on the other hand, has very limited access to
computer resources by default, you need to explicitly assign permissions
to this account to use resources on the computer. That is, when you place
a program to a computer running as services, you should start with a most
restricted user account and only assign access permissions as needed. In
your case, it is good choice to use Local Service account, but you need to
explicitly allow this account to read/write to the floder where *.mdb
sits. Of course you can choose other user account to run the windows
service as long as the account has sufficient access permissions.

"sloan" <sl***@ipass.netwrote in message
news:OH**************@TK2MSFTNGP05.phx.gbl...
>>
I'm guessing your db isn't configured to allow permissions from the
(being used) user.

2 suggestions:
Switch to sql authentication.

Figure out ( and give permissions ) to the correct user for your db.
Here is some crappy code to figure out (so you can log it) the user.
You're thinking "I know who the user is", but sometimes its good to do it
while in the code.

Go to Control Panel / Users and you can see a list of "built in" users
that
a windows machine has.

private string FindIIdentity()

{

try

{

string returnValue = string.Empty;

WindowsIdentity ident = WindowsIdentity.GetCurrent();

returnValue = ident.Name;

try

{

returnValue += " on " + System.Environment.MachineName;

}

catch (Exception ex)

{

}

return returnValue;

}

catch (Exception ex)

{

return "Error Finding Identity";

}

}


"Matt Lowrance" <ma*************@gmail.comwrote in message
news:87**********************************@a1g2000 hsb.googlegroups.com...
>>I'm hoping someone can give me a little guidance. I have written a
simple Windows Service that goes out and scrapes a few web pages and
updates some data in an access database. The service works correctly
in the IDE and trying to be a good citizen I set it to run as "Local
Service" when I install it.

However once installed it fails silently. My log eventlog message
saying the the DB was updated successfully is written, however the
actual write to the database doesn't happen. There does not seem to
be an error or exception that I can catch, it just doesn't write.

Once I change the service to run as "Local System" it works
correctly. So my question is should I really avoid using "Local
System". I have read the articles explaing he dangers, yet I see lots
of services running as it on my system. Maybe its more like a
guidance "Do so if you can, but if not don't worry too much about it?"
Is there another option? Is there a better way to know where the
problem with the "Local Service" account exists? Like I said when I
debug it in the IDE it works correctly, but at that point it is
running as my user account (which apparently has all the rights it
needs).

Should I just create another user account and play with the permission
until I find the right ones. This service goes out to client
locations so I hate to make them do too much manual work in creating
an account (as some clients I doubt would even know how to do it),
etc?

Thanks,

Matt



Jul 31 '08 #4

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

Similar topics

2
by: cd | last post by:
Is there a specific process or permissions that must be granted to get a .NET (framework 1.4) Window Service to run properly on a Windows 2003 Server? I built a Windows Service to start two local...
9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
3
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim...
4
by: SQLScott | last post by:
My esteemed VB.Net gurus, I posted this question a week or so ago and recieved 1 response that helped me somewhat but really did not solve the problem (but I do appreciate the response). I...
3
by: Miriam | last post by:
Hello, I created a Windows Service in VB.NET, which is to purge files periodically in the local system and also in the shared network drive. Here is my problem: 1. If I set the “Account”...
27
by: pisquem | last post by:
I am building an windows service that is to be deployed on a windows server 2003 and I want to have activity written to the event log, I want its own log called ('CustomLog') Below is what I...
10
by: dermot | last post by:
I have wrriten a small windows service application in visual studio ..net 2003 which listens for incoming FTP files. These files would overwrite over time due to duplicate file names. However any...
7
by: torus | last post by:
Is the aspnet account called "aspnet" for all non-English versions of Windows and IIS?
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.