Hi,Does ldaptive support this scenario?
- Application server (say, Tomcat) authenticates clients by Kerberos. So it has a keytab file for a valid Active Directory account, used to decrypt and validate clients' tickets.
- It means that the server cannot know passwords of its users.
- Can I use the same keytab to make the server to bind (authenticate) to domain controller's LDAP and then send queries to it in order to discover users' group membership and such?
The JAAS page contains example of Kerberos authentication, but it's hard to understand, which scenario it describes exactly:
- When the server obtains clients' username & password by some means (let's say, login form) and then uses them to bind to LDAP by Kerberos?
- When client delegates its TGT to the server, so the server binds to LDAP on behalf of the client?
- Or when the server performs the bind on its own, as I described above?
ldaptive {
org.ldaptive.jaas.LdapLoginModule required
storePass="true"
ldapUrl="ldap://hostname:port"
dnResolver="org.ldaptive.auth.FormatDnResolver{{format=%s...@domain.com}}"
useStartTLS="true";
org.ldaptive.jaas.LdapRoleAuthorizationModule required
useFirstPass="true"
ldapUrl="ldap://hostname:port"
bindSaslConfig="{mechanism=GSSAPI}"
baseDn="ou=people,dc=org1,dc=org"
roleFilter="(sAMAccountName={user})"
roleAttribute="mail";
};
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt="true"
debug="true"
principal="SERVICE-PRINCIPAL"
useKeyTab="true"
keyTab="/path/to/krb5.keytab";
}; -Djava.security.auth.login.config=/path/to/jaas.config
-Djava.security.krb5.realm=DOMAIN.COM
-Djava.security.krb5.kdc=HOSTNAME
-Djavax.security.auth.useSubjectCredsOnly=false
Daniel, thanks a lot! It works exactly in the fashion that I was looking for!I had, though, to search for some additional options not appearing on the JAAS page, such as subtreeSearch. The critical bindSaslConfig parameter isn't documented there as well.jaas.conf:
Can I ask you some more questions, if you don't mind?
- Is there a way to make LdapRoleAuthorizationModule to discover nesting of AD groups? Currently it just finds out the groups the user belongs to directly.
- The so-called "Primary Group" (which is usually "Domain Users") is a special case: it doesn't list its members in "member" attribute, and they don't list it in their "memberof" attribute. Instead, user objects list its RID in their PrimaryGroupID attribute (513 for "Domain Users"). Can LdapRoleAuthorizationModule find out the Primary Group in some way?
- When requesting Kerberos ticket to the LDAP service, the LdapDnAuthorizationModule builds SPN by prepending "ldap/" to hostname specified in the ldapUrl. So in my case it will be "ldap/dc1.mydomain.local". This actually forces me to specify specific DC in the ldapUrl, which, of course, is problematic - what happens if the DC isn't reachable for some reason? Can we do better than this? For example, when binding to LDAP with username & password, I can specify ldapUrl in "ldap://mydomain.local:389" form - the actual DC will be resolved by DNS in round-robin fashion. But with Kerberos such URL results in invalid SPN! Is there a way to make the login modules to resolve the _ldap._tcp.mydomain.local SRV records, like it's done with KDC, or something like this?
- I've paid attention that during the Kerberos authentication to LDAP, the LDAP server doesn't return the AP-REP ticket - the cryptographic proof of its identity. I guest it doesn't because the client (Tomcat) doesn't require it to do so. Can we force Krb5LoginModule to request this ticket from LDAP and to check it?
On Tue, Oct 28, 2014 at 10:14 AM, Cat Mucius <muc...@wirade.ru> wrote:
- The so-called "Primary Group" (which is usually "Domain Users") is a special case: it doesn't list its members in "member" attribute, and they don't list it in their "memberof" attribute. Instead, user objects list its RID in their PrimaryGroupID attribute (513 for "Domain Users"). Can LdapRoleAuthorizationModule find out the Primary Group in some way?
You could write an entry handler that searches for the group DN. (Similar to what the recursive entry handler does.) File a feature request for this if you want. Ldaptive already has some components for dealing with AD specific attributes.
- When requesting Kerberos ticket to the LDAP service, the LdapDnAuthorizationModule builds SPN by prepending "ldap/" to hostname specified in the ldapUrl. So in my case it will be "ldap/dc1.mydomain.local". This actually forces me to specify specific DC in the ldapUrl, which, of course, is problematic - what happens if the DC isn't reachable for some reason? Can we do better than this? For example, when binding to LDAP with username & password, I can specify ldapUrl in "ldap://mydomain.local:389" form - the actual DC will be resolved by DNS in round-robin fashion. But with Kerberos such URL results in invalid SPN! Is there a way to make the login modules to resolve the _ldap._tcp.mydomain.local SRV records, like it's done with KDC, or something like this?
You can configure multiple URLs like so:ldapUrl="ldap://dc1.mydomain.local:3268 ldap://dc2.mydomain.local:3268 ..."and also specify a connection strategy:connectionStrategy="ACTIVE_PASSIVE"I know that not exactly what you want, so please file a feature request on the SRV functionality.