networkcredentials

store and get generic credentials with an intranet application


I developed an Intranet application which needs to realize a "git push" from a local repository (on the disk of the web server) to a remote repository. I launch the git process from the web server, it runs under the IIS pool identity which is a domain account member of the administrators group of the web server machine. Git needs the user credentials to perform the push action. I integrated a custom version of git-credential-winstore. This program uses the Windows Credential Manager to store generic credentials for a web site. But when the call to the credential's write occurs, I get the error :

Failed to write credential: A specified logon session does not exist. It may already have been terminated

I checked the policy "Network access: Do not allow storage of passwords and credentials for network authentication", it is disabled.

What goes wrong here ?


Solution

  • Pool account needs to gain access to its user profile. So we need to connect one time to a Windows Session to create user profile (I think it's necessary). Next in the Advanced Settings of the dedicated Application Pool, set "Load User Profile" = true.

    Note about credentials : Windows credential target must be changed to manage different users in the same Windows vault. I change "git:https://remote-host" by "git_USERID:https://remote-host".