X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FLdapCommon%2FLdapCommon.php;fp=plugins%2FLdapCommon%2FLdapCommon.php;h=579fe4b64b474fe649198170037e9c1ba1a6ad33;hb=59119482ca34540bd7f0a2a1aa994de1d5328ea2;hp=09ff54bad9fca7161f7b69103f6b6d6c4d8c979d;hpb=2db8aa3ec3f6804f8f16efe754aafb149f4035c9;p=quix0rs-gnu-social.git diff --git a/plugins/LdapCommon/LdapCommon.php b/plugins/LdapCommon/LdapCommon.php index 09ff54bad9..579fe4b64b 100644 --- a/plugins/LdapCommon/LdapCommon.php +++ b/plugins/LdapCommon/LdapCommon.php @@ -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 { - }