How to acquire a floating license as LocalService user? Or: how to return a floating license?

My company uses the floating license system.

  1. I have a process that I want to run as the LocalService user on Windows. This is a particularly disempowered user, but I have reasons for doing this.
    Anyway, if I start a freshly-built Windows server, it will be unable to obtain a license as LocalService. The Unity.Licensing.Client process will successfully complete with no error code or error logs, but the license server is not contacted and no license is obtained. Unity itself will then encounter licensing errors when we try to run it.
    However, if I log into that server as Administrator, and then acquire a floating license as Administrator, then LocalService will be able to do it too!
    This kind of problem makes me suspect that there’s an issue with creating a directory or a file somewhere, but I haven’t been able to pin down the problem. Somehow, once I’ve obtained a license once as Administrator, then I can obtain them as LocalService.
    This would be fine… except now I’m using up two times as many licenses as I should! I can see on the Licensing Server that I have one license obtained for Administrator, and another for LocalService.

  2. So, okay, another option would be to obtain a floating license as Administrator and then immediately return it. But I can find no documentation about how to actually do this. Unity.Licensing.Client.exe does have a --return-floating option, but I need to use “the given token”. I can see the tokens if I log into the licensing server and obtain the currently assigned tokens, but there does not seem to be an option in Unity.Licensing.Client to list the ones assigned to the current machine/user. I’ve seen some indications there would be license files locally, but I see nothing like that.

Never mind, I realized it was printing the token on STDOUT the whole time:

Client product version: 1.6.2+1.91f8005
Trying to acquire floating license from: 123.456.789.999 ...
License lease Created with token bdb2238d-7ee8-41ef-ba58-782daeecc675. Expires: Wednesday, September 20, 2023 5:42:39 PM

So that’s easy to solve, I just parse STDOUT and keep that token around to return later.