Question

I'm trying to perform kerberos authentication using java.

I enabled debugging.

When trying to connect to the LDAP using the tgt, I'm getting (the server names were changed):

getRealmFromDNS: trying srv1.myserver.com
getRealmFromDNS: trying srv2.myserver.com
getRealmFromDNS: trying srv1.myserver.com
getRealmFromDNS: trying srv2.myserver.com
Found ticket for user@SUB.MYSERVER.COM to go to krbtgt/SUB.MYSERVER.COM@SUB.MYSERVER.COM expiring on Sat Dec 01 02:11:14
Entered Krb5Context.initSecContext with state=STATE_NEW
Service ticket not found in the subject
getRealmFromDNS: trying srv1.myserver.com
getRealmFromDNS: trying srv2.myserver.com
>>> Credentials acquireServiceCreds: same realm
default etypes for default_tgs_enctypes: 16 3 1.
>>> CksumType: sun.security.krb5.internal.crypto.RsaMd5CksumType
>>> EType: sun.security.krb5.internal.crypto.ArcFourHmacEType
>>> KdcAccessibility: reset
getKDCFromDNS using UDP
>>> KrbKdcReq send: kdc=server123.myserver.com. UDP:88, timeout=30000, number of retries =3, #bytes=1542
>>> KDCCommunication: kdc=server123.myserver.com. UDP:88, timeout=30000,Attempt=1, #bytes=1542
SocketTimeOutException with attempt: 1
>>> KDCCommunication: kdc=server123.myserver.com. UDP:88, timeout=30000,Attempt=2, #bytes=1542
SocketTimeOutException with attempt: 2
>>> KDCCommunication: kdc=server123.myserver.com. UDP:88, timeout=30000,Attempt=3, #bytes=1542
SocketTimeOutException with attempt: 3
>>> KrbKdcReq send: error trying server123.myserver.com.
java.net.SocketTimeoutException: Receive timed out
        at java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
        at java.net.DualStackPlainDatagramSocketImpl.receive0(Unknown Source)
        at java.net.AbstractPlainDatagramSocketImpl.receive(Unknown Source)
        at java.net.DatagramSocket.receive(Unknown Source)
        at sun.security.krb5.internal.UDPClient.receive(Unknown Source)
        at sun.security.krb5.KdcComm$KdcCommunication.run(Unknown Source)
        at sun.security.krb5.KdcComm$KdcCommunication.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.security.krb5.KdcComm.send(Unknown Source)
        at sun.security.krb5.KdcComm.send(Unknown Source)
        at sun.security.krb5.KdcComm.send(Unknown Source)
        at sun.security.krb5.KrbTgsReq.send(Unknown Source)
        at sun.security.krb5.KrbTgsReq.sendAndGetCreds(Unknown Source)
        at sun.security.krb5.internal.CredentialsUtil.serviceCreds(Unknown Source)
        at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(Unknown Source)
        at sun.security.krb5.Credentials.acquireServiceCreds(Unknown Source)
        at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
        at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
        at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
        at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(Unknown Source)
        at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(Unknown Source)
        at com.sun.jndi.ldap.LdapClient.authenticate(Unknown Source)
        at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
        at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
        at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
        at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source)
        at myApp.JndiAction.performJndiOperation(MyTest.java:577)
        at myApp.JndiAction.run(MyTest.java:551)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Unknown Source)
        at myApp.MyTest.main(MyTest.java:489)
>>> KdcAccessibility: add server123.myserver.com.

My answers are:

  1. From where it got the kdc server (server123.myserver.com)?

  2. Can I change it?

Thanks.

Was it helpful?

Solution

If you're not on a Windows platform, search for the krb5.conf file. There is a [realms] section where the domain and associated KDCs are provided.

[realms]
        YOURDOMAIN.com = {
                kdc = dc1.yourdomain.com
        }

On a Windows platform, there are specific DNS records as Michael-O noted.

OTHER TIPS

This is from DNS (SRV records for Kerberos). Ask your admin to check that faulty server and correct the DNS entries if possible. This is not a Java problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top