I am writing a Windows Service in python and I am using the keyring module to safely store credentials that I need to use regularly and persistently. This means that keyring stores the passwords using the local system user credentials.
All I do is use the 2 basic keyring functions: get_password(SERVICE_NAME, username, password)
and
set_password(SERVICE_NAME, username)
. I don't preconfigure keyring as I understood it and saw that it configures its backend automatically.
When I run this on Windows Server 2008 and above everything works smoothly. But when I run this on Windows Server 2003, I get this nasty error:
error: (1312, 'CredWrite', 'A specified logon session does not exist. It may already have been terminated.')
I assume it has something to do with the logon session of the local system user that is used to run my service, though it is peculiar since I understood it's a form of ultra-admin-super-user that's supposed to have permissions to do anything it wants in the system. But when I change the logon credentials of the user to the local Administrator, everything works smoothly.
Is there something I need to change in the configuration of my service for this to work? Or change the security policies of the local system user? Or should I ask users to run this service with the local administrator credentials?