]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/LdapCommon/LdapCommon.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / LdapCommon / LdapCommon.php
index 09ff54bad9fca7161f7b69103f6b6d6c4d8c979d..579fe4b64b474fe649198170037e9c1ba1a6ad33 100644 (file)
@@ -60,13 +60,13 @@ class LdapCommon
         $this->ldap_config = $this->get_ldap_config();
 
         if(!isset($this->host)){
-            throw new Exception("must specify a host");
+            throw new Exception(_m("A host must be specified."));
         }
         if(!isset($this->basedn)){
-            throw new Exception("must specify a basedn");
+            throw new Exception(_m('"basedn" must be specified.'));
         }
         if(!isset($this->attributes['username'])){
-            throw new Exception("username attribute must be set.");
+            throw new Exception(_m('The username attribute must be set.'));
         }
     }
 
@@ -179,7 +179,7 @@ class LdapCommon
                 $ldap = $this->get_ldap_connection($config);
 
                 $entry = $this->get_user($username,array(),$ldap);
-                
+
                 $newCryptedPassword = $this->hashPassword($newpassword, $this->password_encoding);
                 if ($newCryptedPassword===false) {
                     return false;
@@ -260,15 +260,14 @@ class LdapCommon
      * @return string The hashed password.
      *
      */
-
-    function hashPassword( $passwordClear, $encodageType ) 
+    function hashPassword( $passwordClear, $encodageType )
     {
         $encodageType = strtolower( $encodageType );
         switch( $encodageType ) {
-            case 'crypt': 
-                $cryptedPassword = '{CRYPT}' . crypt($passwordClear,$this->randomSalt(2)); 
+            case 'crypt':
+                $cryptedPassword = '{CRYPT}' . crypt($passwordClear,$this->randomSalt(2));
                 break;
-                
+
             case 'ext_des':
                 // extended des crypt. see OpenBSD crypt man page.
                 if ( ! defined( 'CRYPT_EXT_DES' ) || CRYPT_EXT_DES == 0 ) {return FALSE;} //Your system crypt library does not support extended DES encryption.
@@ -351,8 +350,7 @@ class LdapCommon
      * @param int $length The length of the salt string to generate.
      * @return string The generated salt string.
      */
-     
-    function randomSalt( $length ) 
+    function randomSalt( $length )
     {
         $possible = '0123456789'.
             'abcdefghijklmnopqrstuvwxyz'.
@@ -366,10 +364,8 @@ class LdapCommon
 
         return $str;
     }
-
 }
 
 class LdapInvalidCredentialsException extends Exception
 {
-
 }