r107411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107410‎ | r107411 | r107412 >
Date:20:14, 27 December 2011
Author:laner
Status:ok
Tags:
Comment:
Fixing static calls to LdapAuthenticationPlugin
Modified paths:
  • /trunk/extensions/LdapAuthentication/LdapAuthentication.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php
@@ -633,15 +633,15 @@
634634 // anything back, then the user exists.
635635 if ( $this->useAutoAuth() && $searchstring != '' ) {
636636 // getSearchString is going to bind, but will not unbind
637 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 637+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
638638 return true;
639639 }
640640
641641 // Search for the entry.
642 - $entry = LdapAuthentication::ldap_read( $this->ldapconn, $searchstring, "objectclass=*" );
 642+ $entry = LdapAuthenticationPlugin::ldap_read( $this->ldapconn, $searchstring, "objectclass=*" );
643643
644644 // getSearchString is going to bind, but will not unbind
645 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 645+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
646646 if ( !$entry ) {
647647 $this->printDebug( "Did not find a matching user in LDAP", NONSENSITIVE );
648648 return false;
@@ -702,7 +702,7 @@
703703 $this->printDebug( "Using servers: $servers", SENSITIVE );
704704
705705 // Connect and set options
706 - $this->ldapconn = LdapAuthentication::ldap_connect( $servers );
 706+ $this->ldapconn = LdapAuthenticationPlugin::ldap_connect( $servers );
707707 ldap_set_option( $this->ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3 );
708708 ldap_set_option( $this->ldapconn, LDAP_OPT_REFERRALS, 0 );
709709
@@ -777,7 +777,7 @@
778778 // return true, and will let anyone in!
779779 if ( '' == $this->userdn ) {
780780 $this->printDebug( "User DN is blank", NONSENSITIVE );
781 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 781+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
782782 $this->markAuthFailed();
783783 return false;
784784 }
@@ -813,12 +813,12 @@
814814 $filter = "(" . $aa . ")";
815815 $attributes = array( "dn" );
816816
817 - $entry = LdapAuthentication::ldap_read( $this->ldapconn, $this->userdn, $filter, $attributes );
818 - $info = LdapAuthentication::ldap_get_entries( $this->ldapconn, $entry );
 817+ $entry = LdapAuthenticationPlugin::ldap_read( $this->ldapconn, $this->userdn, $filter, $attributes );
 818+ $info = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $entry );
819819
820820 if ( $info["count"] < 1 ) {
821821 $this->printDebug( "Failed auth attribute check", NONSENSITIVE );
822 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 822+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
823823 $this->markAuthFailed();
824824 return false;
825825 }
@@ -828,14 +828,14 @@
829829 $this->getGroups( $username );
830830
831831 if ( !$this->checkGroups( $username ) ) {
832 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 832+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
833833 $this->markAuthFailed();
834834 return false;
835835 }
836836
837837 $this->getPreferences();
838838
839 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 839+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
840840 } else {
841841 $this->markAuthFailed();
842842 return false;
@@ -959,9 +959,9 @@
960960 // domain credentials for security reasons.
961961 $password = '';
962962
963 - $success = LdapAuthentication::ldap_modify( $this->ldapconn, $this->userdn, $values );
 963+ $success = LdapAuthenticationPlugin::ldap_modify( $this->ldapconn, $this->userdn, $values );
964964
965 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 965+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
966966 if ( $success ) {
967967 $this->printDebug( "Successfully modified the user's password", NONSENSITIVE );
968968 return true;
@@ -1021,13 +1021,13 @@
10221022 if ( '' != $this->realname ) { $values["cn"] = $this->realname; }
10231023 if ( '' != $this->lang ) { $values["preferredlanguage"] = $this->lang; }
10241024
1025 - if ( 0 != sizeof( $values ) && LdapAuthentication::ldap_modify( $this->ldapconn, $this->userdn, $values ) ) {
 1025+ if ( 0 != sizeof( $values ) && LdapAuthenticationPlugin::ldap_modify( $this->ldapconn, $this->userdn, $values ) ) {
10261026 $this->printDebug( "Successfully modified the user's attributes", NONSENSITIVE );
1027 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1027+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
10281028 return true;
10291029 } else {
10301030 $this->printDebug( "Failed to modify the user's attributes", NONSENSITIVE );
1031 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1031+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
10321032 return false;
10331033 }
10341034 } else {
@@ -1120,7 +1120,7 @@
11211121 } else {
11221122 $this->printDebug( "wgLDAPWriteLocation is not set, failing", NONSENSITIVE );
11231123 // getSearchString will bind, but will not unbind
1124 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1124+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
11251125 return false;
11261126 }
11271127 }
@@ -1147,7 +1147,7 @@
11481148 wfRunHooks( 'LDAPSetCreationValues', array( $this, $username, &$values, $writeloc, &$this->userdn, &$result ) );
11491149 if ( ! $result ) {
11501150 $this->printDebug( "Failed to add user because LDAPSetCreationValues returned false", NONSENSITIVE );
1151 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1151+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
11521152 return false;
11531153 }
11541154
@@ -1157,13 +1157,13 @@
11581158 }
11591159
11601160 $this->printDebug( "Adding user", NONSENSITIVE );
1161 - if ( LdapAuthentication::ldap_add( $this->ldapconn, $this->userdn, $values ) ) {
 1161+ if ( LdapAuthenticationPlugin::ldap_add( $this->ldapconn, $this->userdn, $values ) ) {
11621162 $this->printDebug( "Successfully added user", NONSENSITIVE );
1163 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1163+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
11641164 return true;
11651165 } else {
11661166 $this->printDebug( "Failed to add user", NONSENSITIVE );
1167 - LdapAuthentication::ldap_unbind( $this->ldapconn );
 1167+ LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
11681168 return false;
11691169 }
11701170 } else {
@@ -1446,14 +1446,14 @@
14471447
14481448 $this->printDebug( "Using base: $base", SENSITIVE );
14491449
1450 - $entry = LdapAuthentication::ldap_search( $this->ldapconn, $base, $filter, $attributes );
1451 - if ( LdapAuthentication::ldap_count_entries( $this->ldapconn, $entry ) == 0 ) {
 1450+ $entry = LdapAuthenticationPlugin::ldap_search( $this->ldapconn, $base, $filter, $attributes );
 1451+ if ( LdapAuthenticationPlugin::ldap_count_entries( $this->ldapconn, $entry ) == 0 ) {
14521452 $this->printDebug( "Couldn't find an entry", NONSENSITIVE );
14531453 $this->fetchedUserInfo = false;
14541454 return '';
14551455 }
14561456
1457 - $this->userInfo = LdapAuthentication::ldap_get_entries( $this->ldapconn, $entry );
 1457+ $this->userInfo = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $entry );
14581458 $this->fetchedUserInfo = true;
14591459 if ( isset( $this->userInfo[0][$searchattr] ) ) {
14601460 $username = $this->userInfo[0][$searchattr][0];
@@ -1493,8 +1493,8 @@
14941494 // Don't fetch the same data more than once
14951495 // TODO: use memcached here
14961496
1497 - $entry = LdapAuthentication::ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) );
1498 - $userInfo = LdapAuthentication::ldap_get_entries( $this->ldapconn, $entry );
 1497+ $entry = LdapAuthenticationPlugin::ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) );
 1498+ $userInfo = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $entry );
14991499 if ( $userInfo["count"] < 1 ) {
15001500 return;
15011501 } else {
@@ -1658,10 +1658,10 @@
16591659 }
16601660 } else {
16611661 $this->printDebug( "Searching for the groups", NONSENSITIVE );
1662 - $this->userLDAPGroups = LdapAuthentication::ldap_searchGroups( $usertopass );
 1662+ $this->userLDAPGroups = LdapAuthenticationPlugin::ldap_searchGroups( $usertopass );
16631663
16641664 if ( $this->getConf( 'GroupSearchNestedGroups' ) ) {
1665 - $this->userLDAPGroups = LdapAuthentication::ldap_searchNestedGroups( $this->userLDAPGroups );
 1665+ $this->userLDAPGroups = LdapAuthenticationPlugin::ldap_searchNestedGroups( $this->userLDAPGroups );
16661666 $this->printDebug( "Got the following nested groups:", SENSITIVE, $this->userLDAPGroups["dn"] );
16671667 }
16681668 }
@@ -1669,7 +1669,7 @@
16701670 // Only find all groups if the user has any groups; otherwise, we are
16711671 // just wasting a search.
16721672 if ( $this->getConf( 'GroupsPrevail' ) && count( $this->userLDAPGroups ) != 0 ) {
1673 - $this->allLDAPGroups = LdapAuthentication::ldap_searchGroups( '*' );
 1673+ $this->allLDAPGroups = LdapAuthenticationPlugin::ldap_searchGroups( '*' );
16741674 }
16751675 }
16761676 }
@@ -1697,7 +1697,7 @@
16981698
16991699 $groupstosearch = array( "short" => array(), "dn" => array() );
17001700 foreach ( $groups["dn"] as $group ) {
1701 - $returnedgroups = LdapAuthentication::ldap_searchGroups( $group );
 1701+ $returnedgroups = LdapAuthenticationPlugin::ldap_searchGroups( $group );
17021702 $this->printDebug( "Group $group is in the following groups:", SENSITIVE, $returnedgroups["dn"] );
17031703 foreach ( $returnedgroups["dn"] as $searchme ) {
17041704 if ( in_array( $searchme, $searchedgroups["dn"] ) ) {
@@ -1723,7 +1723,7 @@
17241724
17251725 $searchedgroups = array_merge_recursive( $groups, $searchedgroups );
17261726
1727 - return LdapAuthentication::ldap_searchNestedGroups( $groupstosearch, $searchedgroups );
 1727+ return LdapAuthenticationPlugin::ldap_searchNestedGroups( $groupstosearch, $searchedgroups );
17281728 }
17291729
17301730 /**
@@ -1763,8 +1763,8 @@
17641764 if ( $dn != "*" ) {
17651765 $PGfilter = "(&(distinguishedName=$value)(objectclass=user))";
17661766 $this->printDebug( "User Filter: $PGfilter", SENSITIVE );
1767 - $PGinfo = LdapAuthentication::ldap_search( $this->ldapconn, $base, $PGfilter );
1768 - $PGentries = LdapAuthentication::ldap_get_entries( $this->ldapconn, $PGinfo );
 1767+ $PGinfo = LdapAuthenticationPlugin::ldap_search( $this->ldapconn, $base, $PGfilter );
 1768+ $PGentries = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $PGinfo );
17691769 if ( $PGentries ) {
17701770 $Usid = $PGentries[0]['objectsid'][0];
17711771 $PGrid = $PGentries[0]['primarygroupid'][0];
@@ -1787,8 +1787,8 @@
17881788 }
17891789 $PGfilter = "(&(objectSid=$PGsid_string)(objectclass=$objectclass))";
17901790 $this->printDebug( "Primary Group Filter: $PGfilter", SENSITIVE );
1791 - $info = LdapAuthentication::ldap_search( $this->ldapconn, $base, $PGfilter );
1792 - $PGentries = LdapAuthentication::ldap_get_entries( $this->ldapconn, $info );
 1791+ $info = LdapAuthenticationPlugin::ldap_search( $this->ldapconn, $base, $PGfilter );
 1792+ $PGentries = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $info );
17931793 array_shift( $PGentries );
17941794 $dnMember = strtolower( $PGentries[0]['dn'] );
17951795 $groups["dn"][] = $dnMember;
@@ -1808,7 +1808,7 @@
18091809
18101810 $this->printDebug( "Search string: $filter", SENSITIVE );
18111811
1812 - $info = LdapAuthentication::ldap_search( $this->ldapconn, $base, $filter );
 1812+ $info = LdapAuthenticationPlugin::ldap_search( $this->ldapconn, $base, $filter );
18131813 if ( !$info ) {
18141814 $this->printDebug( "No entries returned from search.", SENSITIVE );
18151815
@@ -1817,7 +1817,7 @@
18181818 return array( "short" => array(), "dn" => array() );
18191819 }
18201820
1821 - $entries = LdapAuthentication::ldap_get_entries( $this->ldapconn, $info );
 1821+ $entries = LdapAuthenticationPlugin::ldap_get_entries( $this->ldapconn, $info );
18221822
18231823 if ( $entries ){
18241824 // We need to shift because the first entry will be a count
@@ -1995,9 +1995,9 @@
19961996 function bindAs( $userdn = null, $password = null ) {
19971997 // Let's see if the user can authenticate.
19981998 if ( $userdn == null || $password == null ) {
1999 - $bind = LdapAuthentication::ldap_bind( $this->ldapconn );
 1999+ $bind = LdapAuthenticationPlugin::ldap_bind( $this->ldapconn );
20002000 } else {
2001 - $bind = LdapAuthentication::ldap_bind( $this->ldapconn, $userdn, $password );
 2001+ $bind = LdapAuthenticationPlugin::ldap_bind( $this->ldapconn, $userdn, $password );
20022002 }
20032003 if ( !$bind ) {
20042004 $this->printDebug( "Failed to bind as $userdn", NONSENSITIVE );

Status & tagging log