Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:36:01+00:00 2026-05-22T21:36:01+00:00

We have a build process that needs to decrypt a password which it then

  • 0

We have a build process that needs to decrypt a password which it then uses to connect to a database. We are using the Data Protection API (DPAPI) to encrypt the password at the machine scope on the build server (I’m logged in with my own domain account) using PowerShell:

[Security.Cryptography.ProtectedData]::Protect( $passwordBytes, $null, [Security.Cryptography.DataProtectionScope]::LocalMachine );

The decryption is also done in a PowerShell script, which is executed by CruiseControl.NET, running as our build user:

 [Security.Cryptography.ProtectedData]::Unprotect( $encryptedbytes, $null, [Security.Cryptography.DataProtectionScope]::LocalMachine );

The call to Unprotect, however, fails with the following message: “Key not valid for use in specified state.”. According to the docs, this error can occur using impersonation, and the impersonating code should load the user’s profile.

For security purposes, the build user is denied the Log on through Terminal Services right. To test the problem, I logged into the build server as myself, then used runas to open a PowerShell prompt as the build user:

runas /profile /user:DOMAIN\BUILDUSER powershell.exe

I then run the PowerShell script to unprotect/decrypt the password, and get the same error.

I used Process Monitor to watch for any failures or access denied events, and there weren’t any.

I’m able to decrypt the password when I log in with my own domain account.

What’s going on? Is my build user’s profile not being loaded? Is there some security setting somewhere I don’t know about to enable this? Why can’t I decrypt the password?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:36:02+00:00Added an answer on May 22, 2026 at 9:36 pm

    Developer error. It turns out I was encrypting at the CurrentUser scope, not the LocalMachine scope. I updated my script and everything is working now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using Maven for a large build process (> 100 modules). We have
I have to build an HTML table that shows data for users versus pages
We have some nightly build machines that have the cuda libraries installed, but which
Have a build process that can't be edited and need to pack another war
Background: I have a post-build process that copies a file to another location. It
I have a server process built in Delphi/C++Builder with RemObjects SDK which claims to
I have build server inside our domain (and it needs to be because it
I have a build script and as part of that script it copies a
I have a J2EE application that needs to be distributed to customers, who will
I have an application which needs to define indexes in various .h files in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.