dotnet/Kerberos.NET

Cannot request a ticket until a user is authenticated

hwjensen opened this issue · 4 comments

Is your feature request related to a problem? Please describe.
Kerberos fails with a message that is hard to understand.

Describe the solution you'd like
I would like to understand the error message.

Describe alternatives you've considered
Reading the code. This will be the next step if this fails.

Additional context
---> OracleInternal.Network.NetworkException (0x80004005): NA Kerberos5: Authentication handshake failure at stage: %s
---> System.InvalidOperationException: Cannot request a service ticket until a user is authenticated
at Kerberos.NET.Client.KerberosClient.CopyTicket(String spn) in D:\a\1\s\Kerberos.NET\Client\KerberosClient.cs:line 1092
at Kerberos.NET.Client.KerberosClient.GetServiceTicket(RequestServiceTicket rst, CancellationToken cancellation) in D:\a\1\s\Kerberos.NET\Client\KerberosClient.cs:line 591
at OracleInternal.Network.AnoKerberos.Authenticate(String KRB5Conf, String KRB5CCName, String SN, String Host, Byte[]& kkey)
at OracleInternal.Network.Ano.KerberosHandshake(AuthenticationService AS, String KRB5Conf, String KRB5CCName)
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName, ConnectionOption CO)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)
at OracleInternal.ConnectionPool.PoolManager3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch) at OracleInternal.ConnectionPool.OracleConnectionDispenser3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
2023-07-19 15:58:41.862121 TID:9 (PRI) (EXT) OracleConnectionDispenser.Get()
The user is authenticated so what is the problem?
KR
Henrik

OK, Thanks, I am guessing that what is going on is that we are trying to use kerberos in a way that was not intended.
We are already using kerberos without problems in an earlier version of Oracle client. It appears that in this new implementation we shall have to implement code that retrieves the TGT from the DC and loads the cache with this before a logon can be attempted. Do you know of example code that can get us started? We would like to work with others on this
this code will probably be needed by a lot of people who wants to use Kerberos.Net in an AD context. I am not sure this is the right forum for this though, do you know of a better place?

TIA
Henrik

It turns out that if the cache is initialized before the authorization process the ticket exchange actually works. The Bruce/kinit failed for some reason, but an old okinit from 12c database we had, did initialize the cache and that did the trick. So now there is a new problem, but this is probably with the 19c database.

Thank you for your help!
KR
Henrik