title: Accessing current user personal certificate store within windows service
body: <p>I am working on an application which accesses a x.509 certificate from the current user store. This works fine when the application is run as an executable.</p>
  
  <p>However, when I try running the app as a windows service, it fails to find the certificate. I tried changing the LogOn property for the windowsservice console to set the right user, but that did not help.</p>
  
  <p>Is there any way I can access the particular user's (Administrator) certificate store? I am bound to use the certificate in the user store - else I can easily use the local machine store.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>I am using this particular piece of code to retrieve certificate:</p>
  
  <pre><code>                        serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "My-CertificateName");
  </code></pre>
  
  <p>This works fine when running as an executable - but fails to find a certificate when running as a windows service</p>