Extension:LDAP Authentication:LDAPGroupsPrevail

The following code is dual licensed under the GPL and the GFDL. Please view the wiki source of this page before copying, so that all lines end p correct in your patch file, or it might turn your sorce code into a cute tiny little green dragon with blue eyes!

--- mediawiki-auth-ldap-0.1.orig/LdapAuthentication.php +++ mediawiki-auth-ldap-0.1/LdapAuthentication.php @@ -1243,7 +1243,10 @@ 		$nameattribute = $wgLDAPGroupNameAttribute[$_SESSION['wsDomain']]; //Search for the groups this user is in -		$filter = "(&($attribute=". $this->getLdapEscapedString($dn). ")(objectclass=$objectclass))"; +               $value = $dn; +		if ($value != '*') +                $value = $this->getLdapEscapedString($value); +		$filter = "(&($attribute=$value)(objectclass=$objectclass))"; $this->printDebug("Search string: $filter",2); @@ -1324,8 +1327,16 @@ 	 * @access private */ 	function setGroups( &$user ) { +	       global $wgGroupPermissions, $wgLDAPGroupsPrevail; + 		$this->printDebug("Pulling groups from LDAP.",1); +		# Add ldap groups as local groups +		if ($wgLDAPGroupsPrevail[$_SESSION['wsDomain']]) +		       foreach ($this->allLDAPGroups as $ldapgroup) +			       if (!array_key_exists($ldapgroup, $wgGroupPermissions)) +				       $wgGroupPermissions[$ldapgroup] = array; + 		# add groups permissions $localAvailGrps = $user->getAllGroups; $localUserGrps = $user->getEffectiveGroups;