This is to raise issue with Microsoft for “DPAPI”.
DPAPI stands for “Data Protection Application Programming Interface”, a built in component in windows 200x servers and used by developers for encryption/decryption of text/string like passwords.
We need to know if there is any specification for “DPAPI” when it is used by any application in Windows Terminal Server (Farm Environment) which has both Roaming profile functionality and Folder Redirection configured.
We are asking this because our customer is facing issues in using client app for above mentioned configuration of windows server and has escalated this. Currently we see it to be a configuration issue of their windows server.
Issue Details:
Our client app use DPAPI to encrypt and then decrypt specific user settings which are to be saved in file in the roaming folder location, something like this à C:\Users\<user-name>\AppData\Roaming\XYZ.
DPAPI works in Roaming profile and we use protection scope in DPAPI based on current user (and not local machine) in our client app
Read more details here..
https://support.microsoft.com/en-us/help/309408/how-to-troubleshoot-the-data-protection-api-dpapi#bookmark-1
In a windows terminal server farm, we will have multiple terminal server for load balancing. In this environment, it is not fixed the user will always get logged in to the same terminal server
When user gets logged in to a terminal server other than previous one then issue occurs in client app. When it is launched it shows error. To fix this user needs help of admin.
The reason for this issue is that the encrypted “settings” file of client for that user (in the roaming folder) is not getting decrypted (DPAPI) at this different terminal server where is user is logged in now and thus client show auth failure.
The DPAPI used in the client for decryption throw following exception
[0 2019-04-18 09:35:42.497]<E/Application> 1st chance exception (type=CryptographicException): sender(Name:XYZ.exeThere are no context policies.), exception=Key not valid for use in specified state.
It appear the DPAPI at this terminal server is not at the correct state to decrypt the user file. However as per Microsoft, if we are using “Roaming profile” then DPAPI should be in the correct state and work seamlessly irrespective user is in which computer
but connected to the same AD domain.
Now, why customer is getting this issue if Roaming profile functionality is enabled.
- Is it a configuration issue at customer end.
- Is it something not supported on windows terminal server environment or due to “Folder Redirection”
I hope this information is enough. Let me know if you need more information related to this.