I've working LDAP authentication with the following setup
AuthName "whatever"
AuthType Basic
AuthBasicProvider ldap
AuthLDAPUrl "ldap://server/OU=SBSUsers,OU=Users,OU=MyBusiness,DC=company,DC=local?sAMAccountName?sub?(objectClass=*)"
Require ldap-group CN=MySpecificGroup,OU=Security Groups,OU=MyBusiness,DC=company,DC=local
This works, however I've to put all users I want to authenticate into MySpecificGroup
. But on LDAP server I've configured that MySpecificGroup
also contains the group MyOtherGroup
with another list of users.
But those users in MyOtherGroup
are not authenticated, I've to manually add them all to MySpecificGroup
and basically can't use the nested grouping. I'm using Windows SBS 2003.
Is there a way to configure Apache LDAP to do this? Or is there a problem with possible infinite recursion and thus not allowed?
Besides
AuthLDAPSubGroupDepth
, that is available only in apache 2.4, it is possible, when using Microsoft AD LDAP, to do authorization using nested groups by using LDAP_MATCHING_RULE_IN_CHAIN matching rule. This is much faster than searching subgroups on the client, because it is done on the DC server with less queries over network.The string
1.2.840.113556.1.4.1941
is an OID calledLDAP_MATCHING_RULE_IN_CHAIN
. This OID is assigned by Microsoft to be used with its LDAP implementation (part of Active Directory). You can not use it with other LDAP servers. The human redeable format is:iso(1).member_body(2).us(840).microsoft(113556).ad(1).as_schema(4).LDAP_MATCHING_RULE_IN_CHAIN(1941)
From Microsoft documentation:
See also:
You need to set
AuthLDAPSubGroupDepth
to make this work. The integer you provide here specifies the maximum sub-group nesting depth that will be evaluated before the user search is discontinued.Add this to your config:
More Info: here and here.
It looks like your only option in Apache 2.2 is to list every group that is included by your main authorized group.
This should be reasonable if your nested groups aren't too complicated.
Crossing AD Domains(using two LDAP servers)
You can set up OpenLDAP with the slapd_meta overlay running on your web server to proxy your authentication.
/etc/ldap/slapd.conf should look something like:
Then, your mod_authnz_ldap stanza would look something like:
This will require some massaging to get it to work, but I think this is the general idea.
While the solution provided by @Mircea_Vutcovici worked for me, my only criticism is that people may get squeamish when they see bitwise operators in use.
For instance, I'll be handing over an Apache Bloodhound installation, that uses Apache HTTPd as the front end with AD group auth, to a group of fellow developers. They're going to have issues coming to grips with bitwise operators. Admins will not be as squeamish of course...I hope.
That being said, I have a solution that doesn't use the bitwise operator and that doesn't use multiple ldap-group definitions.
The following config works for me:
The critical part was the following config:
AuthLDAPMaxSubGroupDepth doesn't work by itself, nor when coupled with AuthLDAPSubgroupAttribute. It was only when I used AuthLDAPSubGroupClass that auth against sub groups started working...at least for me and my situation.