How to programmatically clear the Kerberos cache cache

Does anyone know how to clear the Kerberos cache cache on the local computer - using managed \ unmanaegd code?

Thanks in advance!

+7
c ++ c # windows kerberos
source share
4 answers

It seems to me that you need to call LsaCallAuthenticationPackage with KERB_PURGE_TKT_CACHE_REQUEST after using LsaConnectUntrusted or LsaRegisterLogonProcess . Sorry, no specifics, but I don't have my code for this around ...

+4
source share

The easiest way is to take the Microsoft KList source code (included in the SDK \ Samples platform) and do the same ...

+1
source share

There is an example of “managed C #” for cleaning kerberos tickets using pInvoke at https://github.com/ErtiEelmaa/StackOverflow/blob/master/GroupPolicyUtilities.cs

Copy / paste is too long here. It took some time since the structures in pInvoke were invalid (for example, someone, although C ++ LONG is equal to C # LONG and yada-yada), however I tested this and it worked for me.

In addition, I noticed that there are several errors in PurgeTicket on the Windows 2003 klist.c server:

  • it does not clear the answer
  • it double-checks the same “RESULT” instead of checking “RESULT” and then “SUB-RESULT”
+1
source share

Simple, stupid way:

system("kdestroy"); 

Or, if you want to be more legit, just check the source of the kdestroy implementation. krb5_cc_destroy() seems to be the corresponding function call.

0
source share

All Articles