mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 17:18:54 +01:00
Add in sha passwd crypt for ldap (requires mhash to configure and use) ...
Concept by Matt Pavlovich <mpav@algx.net>
This commit is contained in:
parent
a057be8a98
commit
b08b5717b1
@ -101,4 +101,32 @@
|
|||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function passwdhashes($config)
|
||||||
|
{
|
||||||
|
$hashes = array(
|
||||||
|
'des' => 'des',
|
||||||
|
'md5' => 'md5'
|
||||||
|
);
|
||||||
|
if(@function_exists('mhash'))
|
||||||
|
{
|
||||||
|
$hashes += array('sha' => 'sha');
|
||||||
|
}
|
||||||
|
|
||||||
|
while(list($key, $value) = each($hashes))
|
||||||
|
{
|
||||||
|
if($config['ldap_encryption_type'] == $value)
|
||||||
|
{
|
||||||
|
$selected = ' selected';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$selected = '';
|
||||||
|
}
|
||||||
|
$descr = strtoupper($value);
|
||||||
|
|
||||||
|
$out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -144,8 +144,7 @@
|
|||||||
<td>{lang_LDAP_encryption_type}:</td>
|
<td>{lang_LDAP_encryption_type}:</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="newsettings[ldap_encryption_type]">
|
<select name="newsettings[ldap_encryption_type]">
|
||||||
<option value="DES"{selected_ldap_encryption_type_DES}>DES</option>
|
{hook_passwdhashes}
|
||||||
<option value="MD5"{selected_ldap_encryption_type_MD5}>MD5</option>
|
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1156,6 +1156,15 @@
|
|||||||
|
|
||||||
return $ldappassword;
|
return $ldappassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sha_cryptpasswd($userpass)
|
||||||
|
{
|
||||||
|
$hash = base64_encode(mhash(MHASH_SHA1, $userpass));
|
||||||
|
$ldappassword = sprintf('%s%s', '{SHA}', $hash);
|
||||||
|
|
||||||
|
return $ldappassword;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function encrypt_password
|
@function encrypt_password
|
||||||
@abstract encrypt password
|
@abstract encrypt password
|
||||||
@ -1174,6 +1183,19 @@
|
|||||||
$salt = $this->randomstring(8);
|
$salt = $this->randomstring(8);
|
||||||
$e_password = $this->md5_cryptpasswd($password, $salt);
|
$e_password = $this->md5_cryptpasswd($password, $salt);
|
||||||
}
|
}
|
||||||
|
if($GLOBALS['phpgw_info']['server']['ldap_encryption_type'] == 'SHA')
|
||||||
|
{
|
||||||
|
if(@function_exists('mhash'))
|
||||||
|
{
|
||||||
|
$e_password = $this->sha_cryptpasswd($password);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* this should error instead... */
|
||||||
|
$salt = $this->randomstring(8);
|
||||||
|
$e_password = $this->md5_cryptpasswd($password, $salt);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $e_password;
|
return $e_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user