C# and Vault 2025. Logging into Vault from a Windows Service. Is there an example and clear explanation please?

C# and Vault 2025. Logging into Vault from a Windows Service. Is there an example and clear explanation please?

josealberto.torres
Contributor Contributor
814 Views
3 Replies
Message 1 of 4

C# and Vault 2025. Logging into Vault from a Windows Service. Is there an example and clear explanation please?

josealberto.torres
Contributor
Contributor

Hello everyone.

I have created a Windows Service, which must connect to Vault as a Vault user to search and change some descriptions. It does this on specific days and times.

If I run it "by hand" there is no problem. I log in to Vault on the specific day and time and the process is carried out correctly.

But if I try to do the same from the Service, it gets stuck making the connection to Vault.

I have tried to log in both ways (WebServiceManager and ConnectionManager.Login)

 

 

new Autodesk.Connectivity.WebServicesTools.WebServiceManager(mCred)
VDF.Vault.Library.ConnectionManager.LogIn(server, database, user, password, AuthenticationFlags.Standard, null);

ServerIdentities mServerId = new ServerIdentities();
mServerId.DataServer = server; //replace Description by command line args[i]
mServerId.FileServer = server;
string mVaultName = database;
string mUserName = user;
string mPassword = password;
LicensingAgent mLicAgent = LicensingAgent.Client;

 

 

** LicensignAgent.Client (For read/write access) to Vault.

** This works fine if I call it from the desktop, process, etc. But it fails if I do it from a service.

Could someone please provide a clear explanation of:
- How to configure the service: LocalService, NetWorkService, LocalSystem or User (And how to set Username and Password when starting the service from C# code or from InstallUtils)
- How to configure the connection to Vault as a Vault user or Windows user, Autodesk user or ID.
- To make it compatible with the scheduled service. I can't get the service to start from the installer as a domain user, which I think is necessary, or how to have the correct code and combination of the Service and the Vault connection.

Thanks.

Graitec - Spain
0 Likes
Accepted solutions (1)
815 Views
3 Replies
Replies (3)
Message 2 of 4

Markus.Koechl
Autodesk
Autodesk
Accepted solution

I never tried a service to log in to Vault. In theory, the WebServiceManager login with a Vault account is the only path that might work. Autodesk Account/ID or Windows Account would require a logged-in user. The next limitation is the LicensingAgent.Client: I don't think this service starts without a logged-in user, so you might not get a license.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 4

josealberto.torres
Contributor
Contributor

That's right, Markus.

Everything works fine if you run it from a DLL (without a service). Instantiate everything and log in correctly to Vault. And then it runs all the processes correctly.

 

But if I call this same thing from a service, it gets stuck establishing a connection to Vault (after X minutes, it gives an error).

 

I'll try running it from outside the service (a resident program that runs at startup. The Windows user will have already run it, and then it will work).

I'll close the case because I've been testing and browsing the forums for two or three days, but nothing has worked.

 

Thank you for your time and professional opinion.

Graitec - Spain
0 Likes
Message 4 of 4

josealberto.torres
Contributor
Contributor

Hi Markus.

After multiple tests, the only valid option is to start a service (with a user from the specific domain who also has a Vault account) and log in to Vault with the credentials "AuthenticationFlags.WindowsAuthenticationWithCredentials" using that Windows user's data.

I have a lot of questions about this and haven't tried it. I've seen some examples around. But do you have a link or example of this type of connection with Vault?
Would we use LogIn or WebServiceManager to log in?

I'm a bit lost on the syntax and would need an example. I've already downloaded your example from:
https://github.com/koechlm/API-Onboarding-Sample--Vault-Logins
(It's very interesting, but I can't log in with a Windows user)
I'm on a different domain than the Vault server and I connect to it via VPN. So I keep getting an error because I'm not on the same domain.
Is there a site that can provide information on this type of login using a Windows user and connecting via VPN?

 

Others links:

Service run with domain user: https://forums.autodesk.com/t5/vault-customization/vault-2020-login-method-hangs-when-starting-in-wi... 

Search in Community "Connect from Windows Services": Buscar - Autodesk Community


Thank you very much.

Graitec - Spain
0 Likes