Occasionally, users need to run an API program as a Windows service. The problem with this is that the Vault Client needs to store its
client cache files on disk. The default location is the Window's user's application data directory. When running as a service, the Windows account might not have an application data directory. If you need to specify the cache location, you may use this code instead of the normal login API code. Please note that the Windows account running the API code must have full control of the cache directory.
Code: Select all
ServerOperations.client.ClientInstance = new ClientInstance();
ServerOperations.client.ClientInstance.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client, "c:\\path\\to\\cache\\directory");
//This next line seems redundant, but it's important to work around a
//serveroperations bug.
ServerOperations.client.LoginOptions.User = "username";
ServerOperations.client.ClientInstance.Login("http://localhost/VaultService", "username", "password");
ServerOperations.SetRepository("Initial repository");