]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/LdapAuthentication/LdapAuthenticationPlugin.php
Merge ActivitySpam plugin
[quix0rs-gnu-social.git] / plugins / LdapAuthentication / LdapAuthenticationPlugin.php
index 6296bccfad634f99fec624fcf88a6f9ad3aacfa3..38ea6e6592356664bb8289cfa6297d3d186baeb3 100644 (file)
@@ -22,7 +22,7 @@
  * @category  Plugin
  * @package   StatusNet
  * @author    Craig Andrews <candrews@integralblue.com>
- * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -36,16 +36,18 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
     function onInitializePlugin(){
         parent::onInitializePlugin();
         if(!isset($this->attributes['nickname'])){
-            throw new Exception("must specify a nickname attribute");
+            // TRANS: Exception thrown when initialising the LDAP Auth plugin fails because of an incorrect configuration.
+            throw new Exception(_m('You must specify a nickname attribute.'));
         }
         if($this->password_changeable && (! isset($this->attributes['password']) || !isset($this->password_encoding))){
-            throw new Exception("if password_changeable is set, the password attribute and password_encoding must also be specified");
+            // TRANS: Exception thrown when initialising the LDAP Auth plugin fails because of an incorrect configuration.
+            throw new Exception(_m('If password_changeable is set, the password attribute and password_encoding must also be specified.'));
         }
         $this->ldapCommon = new LdapCommon(get_object_vars($this));
     }
 
     function onAutoload($cls)
-    {   
+    {
         switch ($cls)
         {
          case 'LdapCommon':
@@ -63,11 +65,13 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
         {
          case 'register':
             if($this->autoregistration) {
-                $instr = 'Have an LDAP account? Use your standard username and password.';
+                // TRANS: Instructions for LDAP authentication.
+                $instr = _m('Do you have an LDAP account? Use your standard username and password.');
             }
             break;
          case 'login':
-            $instr = 'Have an LDAP account? Use your standard username and password.';
+            // TRANS: Instructions for LDAP authentication.
+            $instr = _m('Do you have an LDAP account? Use your standard username and password.');
             break;
          default:
             return true;
@@ -79,12 +83,12 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
         }
         return true;
     }
-    
+
     //---interface implementation---//
 
     function checkPassword($username, $password)
     {
-        return $this->ldapCommon->checkPassword($username);
+        return $this->ldapCommon->checkPassword($username,$password);
     }
 
     function autoRegister($username, $nickname)
@@ -96,7 +100,12 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
         if($entry){
             $registration_data = array();
             foreach($this->attributes as $sn_attribute=>$ldap_attribute){
-                $registration_data[$sn_attribute]=$entry->getValue($ldap_attribute,'single');
+                //ldap won't let us read a user's password,
+                //and we're going to set the password to a random string later anyways,
+                //so don't bother trying to read it.
+                if($sn_attribute != 'password'){
+                    $registration_data[$sn_attribute]=$entry->getValue($ldap_attribute,'single');
+                }
             }
             if(isset($registration_data['email']) && !empty($registration_data['email'])){
                 $registration_data['email_confirmed']=true;
@@ -118,7 +127,7 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
 
     function suggestNicknameForUsername($username)
     {
-        $entry = $this->ldap_get_user($username, $this->attributes);
+        $entry = $this->ldapCommon->get_user($username, $this->attributes);
         if(!$entry){
             //this really shouldn't happen
             $nickname = $username;
@@ -138,6 +147,7 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
                             'author' => 'Craig Andrews',
                             'homepage' => 'http://status.net/wiki/Plugin:LdapAuthentication',
                             'rawdescription' =>
+                            // TRANS: Plugin description.
                             _m('The LDAP Authentication plugin allows for StatusNet to handle authentication through LDAP.'));
         return true;
     }