First Thing: Know Your Enemy
NTE_BAD_LEN (0x80090004) is a classic DPAPI failure. It means the encryption key Windows uses to protect your data—passwords, certificates, credentials—is the wrong length. That usually means the key got corrupted or the user profile is out of sync. You'll see this in Outlook when it tries to open a password-protected PST, in Windows Hello setup, or when a service tries to decrypt a stored secret. The culprit is almost always a broken DPAPI master key, not your actual password. Good news: you can fix it without nuking your whole profile.
I've fixed this dozens of times. Start with the quick reset. It works 60% of the time. If not, we dig into the profile.
Quick Fix (30 seconds): Kill the Credential Manager Cache
This is the first thing I try. It clears the cached credentials that might be messing with DPAPI. Won't touch your actual passwords, just the stored ones that are likely stale.
- Open Control Panel > Credential Manager.
- Click Windows Credentials.
- Look for any entry related to the app that's failing (Outlook, Remote Desktop, etc.).
- Remove them. Yes, all of them. You'll re-enter passwords later.
If that doesn't cut it, open an elevated Command Prompt and run this to flush the DPAPI cache:
gpupdate /forceThat forces a refresh of policy and sometimes resets the local DPAPI state. Reboot and test. If the error persists, move to the moderate fix.
Moderate Fix (5 minutes): Rebuild the DPAPI Master Key
Here you'll delete the user's DPAPI key folder. The system regenerates it on next login. This is safe—the data encrypted with the old key becomes unrecoverable, but if you're getting this error, that data is already unusable.
- Log into Windows as the affected user.
- Open Run (Win+R) and type
%APPDATA%\Microsoft\Protect. - You'll see a folder with a long GUID name like
{GUID}. That's your DPAPI key container. - Rename that folder to
Protect_Old. Don't delete it—just in case. - Reboot. Windows creates a fresh DPAPI key.
Test your app again. If it still throws 0x80090004, we go nuclear.
Advanced Fix (15+ minutes): Recreate the User Profile
Sometimes the corruption runs deeper than the DPAPI key—the entire user profile is toast. This happens after a botched domain migration or when you've manually messed with profile paths. Don't bother trying to repair the profile in place; I've wasted hours on that. Instead, create a new profile and copy your data over.
- Back up your important files from
C:\Users\<username>to an external drive. Don't skip this. You will lose something otherwise. - Create a new local admin account or use another admin account to do this.
- In System Properties > Advanced > User Profiles, select the broken profile and click Delete. That removes it cleanly.
- Log in with your main account—Windows builds a fresh profile from scratch.
- Copy your files back. Reinstall apps that were only installed for that user (Outlook profiles, etc.).
If the error happens on a domain machine, also check if the user's roaming profile is full of corruption. Delete the NTUSER.DAT from the network share—yes, that's drastic, but it forces a clean profile creation. Back up first.
What If It Still Breaks?
If you've done all this and the error persists, especially on a domain-joined machine, it's time to look at group policy. Some policies block DPAPI access or force old key versions. Run rsop.msc and check Computer Configuration > Windows Settings > Security Settings > Public Key Policies. Look for any setting that disables DPAPI or restricts it. That's rare, but I've seen it.
Also, if this happens after a Windows update, roll back the latest update. I've seen cumulative updates break DPAPI on certain builds—specifically Windows 10 1903 and 2004 had issues.
One last thing: if you're dealing with a smart card or certificate-based login, the error might originate from the certificate store, not DPAPI. Run certmgr.msc, look for expired or corrupted certs, and delete the culprit. But that's a different beast.
Good luck. You'll get this sorted. I've seen it a hundred times, and these three steps have never failed me—except when the hardware was dying, and that's a whole other post.