<p>I'm writing (in C# with .NET 3.5) an administrative application which will poll multiple Windows systems for various bits of data. In many cases it will use WMI, but in some cases it may need to read remote registry or remotely execute some command or script on the polled system. This polling will happen at repeating intervals - usually nightly, but can be configured to happen more (or less) frequently. So the poll could happen as often as every 10 minutes or as rarely as once a month. It needs to happen in an automated way, without any human intervention.</p>

<p>These functions will require admin-level access to the polled systems. Now, I expect that in most use cases, there will be a domain, and the polling application can run as a service with Domain Admin (or equivalent) privileges, which means I do not have to worry about storing passwords - the admin setting up the app will define the service's username/password via standard Windows mechanisms.</p>

<p>But there's always a few black sheep out there. The program may run in nondomain environments, or in cases where some polled systems are not members of the domain. In these cases we will have to define a username and password, store them securely, then invoke this user/pass pair at the time we poll that system. So keep in mind - in this case the program being written <em>is the user</em> who <em>sends</em> password to the authenticating system. </p>

<p>I am not sure whether I will need to use a reversible hash which I then decrypt to plaintext at time of use, or if there is some Windows mechanism which would allow me to store and then reuse the hash only. Obviously the second mechanism is preferable; I'd like my program to either <em>never</em> know the password's plaintext value, or know it for the shortest amount of time possible.</p>

<p>I need suggestions for smart and secure ways to accomplish this.</p>

<p>Thanks for looking!</p>

[{'answer_id': 47263, 'author': '1800 INFORMATION', 'author_id': 3146, 'author_profile': 'https://Stackoverflow.com/users/3146', 'pm_score': 4, 'selected': True, 'text': '<p>The answer is here:</p>\n\n<p><a href="https://stackoverflow.com/questions/40853/how-to-store-passwords-in-winforms-application#40867">How to store passwords in Winforms application?</a></p>\n'}, {'answer_id': 47269, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 0, 'selected': False, 'text': "<p>Well it seems that your program needs to impersonate a user other than the context under which it is already running. Although, it does look like a pretty automated process, but if it's not, can you simply not ask the administrator to put in username and password at the time this 'black-sheep' computer is being polled?</p>\n"}]
['https://Stackoverflow.com/questions/47262', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2383/']