Windows Service needs CSLA authentication

Windows Service needs CSLA authentication

Old forum URL: forums.lhotka.net/forums/t/3044.aspx


Massong posted on Friday, June 15, 2007

Hi all,

We use Electronic Data Interchange (EDI) to get delivery instructions. These delivery instructions are written into a special folder as text files by a third party software. I wrote a Windows Service that observes this folder with a FileSystemWatcher to store all new delivery instructions into our database.

What would be the best practise to authenticate the Windows Service with CSLA authentication? Where do I get the user credentials from? The problem is that a Windows Service should not have – and must start without – user interaction. So I can’t use a log on dialog.

I don’t want to have the user credentials in a config file or hard coded into the service. I could store them in an encrypted file – but then I need a password to decrypt the user credentials…

Thanks for help.

RockfordLhotka replied on Friday, June 15, 2007

You have four basic options:

  1. Windows Registry
  2. app.config
  3. other file
  4. hard code

In the first three cases I would think you'd want the values encrypted. Hard coding is pretty much never good, so I'd pick one of the first three.

The app.config option is probably easiest, because Microsoft already provides a solution for encrypting parts of the config file.

Otherwise look at the old configuration application block from Microsoft patterns and practices, as they had encryption code for this too. They supported registry, config file or other file options. I use past tense, because I don't think that block carried forward once encryption was supported directly in the config files by .NET itself.

Massong replied on Wednesday, June 20, 2007

Hi Rocky,

Thanks for your answer. I didn’t know that it is possible to encrypt parts of App.config. I will give it a try. Thanks.

Copyright (c) Marimer LLC