Kerberos ticket cache location on windows for multiple users

I am using multiple odbc drivers connecting to hive and impala, and most of the documentation states that the kerberos ticket location should be defined by a environment variable KRB5CCNAME, such as C:\temp\kr5ccache

This setup works fine, but I would like to provide for multiple users the possibility to connect the ODBC with different credentials, so the ticket cache location cannot be static, rather it should be user specific. So my question is how to set up an env variable in Windows Server 2012 which will be different for each user. Something like in unix ~/.tmp/krb5ccache.

Thanks


Solution 1:

A ~ tilde occurring as the first character of an argument in Unix/Linux shell/bash is the same as the $HOME environment variable. Windows equivalent is %USERPROFILE%.

You can use any user variable starting with string expanded to. Try your own from an open cmd window: set | find /I "%USERNAME%" and the output looks like

APPDATA=C:\Users\{username}\AppData\Roaming
LOCALAPPDATA=C:\Users\{username}\AppData\Local
PSModulePath=C:\Users\{username}\Documents\WindowsPowerShell\Modules
USERPROFILE=C:\Users\{username}

Hence, you could use something like the following code snippet

set "KRB5CCNAME=%USERPROFILE%\kr5ccache"
rem ensure that above directory exists:
2>NUL md "%KRB5CCNAME%"