Thread:Extension talk:LDAP Authentication/Active Directory group synchronization problems/reply (2)

Thanks Ryan,

For my purposes I hacked it quickly, just wanted to let you know so you could come up with a more appropriate method (for example allowing the user to set the name attribute). :P

The code you posted works fine for groups without spaces given the (\w). I'm not very good with regular expressions so I replaced it the regex (in my case the group happens to be two words).

$groups = array( "dn" => array, "short" => array ); foreach ( $memberOfMembers as $mem ) { array_push( $groups["dn"], strtolower( $mem ) ); if ( isset( $wgLDAPGroupNameAttribute[$_SESSION['wsDomain']] ) ) { $attr = $wgLDAPGroupNameAttribute[$_SESSION['wsDomain']]; } else { $this->printDebug("wgLDAPGroupNameAttribute is not set when trying to do memberOf search; this can be ignored if you aren't doing group synchronization.", NONSENSITIVE); $attr = ""; } 	// simple hackery $memAttrs = explode(',', strtolower($mem)); if (isset( $memAttrs[0] )) $memAttrs = explode('=', $memAttrs[0]); if ( isset( $memAttrs[0] ) && $memAttrs[0] == strtolower($attr) ) { array_push( $groups["short"], strtolower( $memAttrs[1] ) ); } } $this->userLDAPGroups = $groups;

You'll also need a global statement for $wgLDAPGroupNameAttribute