r78236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78235‎ | r78236 | r78237 >
Date:08:21, 12 December 2010
Author:laner
Status:deferred
Tags:
Comment:
Some formatting fixes, and addition of a hook that let's third-party extensions add objectclasses and attributes to created users.
Modified paths:
  • /trunk/extensions/LdapAuthentication/LdapAuthentication.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php
@@ -718,11 +718,11 @@
719719
720720 $this->userdn = $this->getSearchString( $username );
721721 if ( '' == $this->userdn ) {
722 - $this->printDebug( "$this->userdn is blank, attempting to use wgLDAPWriteLocation", NONSENSITIVE );
 722+ $this->printDebug( "userdn is blank, attempting to use wgLDAPWriteLocation", NONSENSITIVE );
723723 if ( isset( $wgLDAPWriteLocation[$_SESSION['wsDomain']] ) ) {
724724 $this->printDebug( "wgLDAPWriteLocation is set, using that", NONSENSITIVE );
725725 $this->userdn = $wgLDAPSearchAttributes[$_SESSION['wsDomain']] . "=" .
726 - $username . "," . $wgLDAPWriteLocation[$_SESSION['wsDomain']];
 726+ strtolower( $username ) . "," . $wgLDAPWriteLocation[$_SESSION['wsDomain']];
727727 } else {
728728 $this->printDebug( "wgLDAPWriteLocation is not set, failing", NONSENSITIVE );
729729 // getSearchString will bind, but will not unbind
@@ -747,8 +747,11 @@
748748 if ( '' != $this->realname ) { $values["cn"] = $this->realname; }
749749 else { $values["cn"] = $username; }
750750 $values["userpassword"] = $pass;
751 - $values["objectclass"] = "inetorgperson";
 751+ $values["objectclass"] = array( "inetorgperson" );
752752
 753+ # Let other extensions modify the user object before creation
 754+ wfRunHooks( 'LDAPSetCreationValues', array( $this, &$values ) );
 755+
753756 if ( isset ( $wgLDAPAuthAttribute[$_SESSION['wsDomain']] ) ) {
754757 $values[$wgLDAPAuthAttribute[$_SESSION['wsDomain']]] = "true";
755758 }
@@ -1752,7 +1755,7 @@
17531756 * @return string
17541757 * @access private
17551758 */
1756 - function getLdapEscapedString ( $string ) {
 1759+ function getLdapEscapedString( $string ) {
17571760 // Make the string LDAP compliant by escaping *, (, ) , \ & NUL
17581761 return str_replace(
17591762 array( "*", "(", ")", "\\", "\x00" ), // replace this
@@ -1768,7 +1771,7 @@
17691772 * @return string
17701773 * @access private
17711774 */
1772 - function getBaseDN ( $type ) {
 1775+ function getBaseDN( $type ) {
17731776 global $wgLDAPBaseDNs, $wgLDAPGroupBaseDNs, $wgLDAPUserBaseDNs;
17741777
17751778 $this->printDebug( "Entering getBaseDN", NONSENSITIVE );

Status & tagging log