diff -up e-smith-base-5.2.0/root/etc/e-smith/web/panels/password/cgi-bin/userpassword.allow-admin-pwd-change e-smith-base-5.2.0/root/etc/e-smith/web/panels/password/cgi-bin/userpassword --- e-smith-base-5.2.0/root/etc/e-smith/web/panels/password/cgi-bin/userpassword.allow-admin-pwd-change 2008-08-20 23:17:24.000000000 +0200 +++ e-smith-base-5.2.0/root/etc/e-smith/web/panels/password/cgi-bin/userpassword 2010-03-09 20:52:12.000000000 +0100 @@ -26,8 +26,10 @@ use strict; use esmith::FormMagick; use esmith::util; use esmith::ConfigDB; +use esmith::AccountsDB; our $configdb = esmith::ConfigDB->open(); +our $accountsdb = esmith::AccountsDB->open(); my $fm = new esmith::FormMagick; $fm->display(); @@ -117,14 +119,47 @@ Validates the password using the desired =cut sub check_password { - my $fm = shift; - my $pass1 = shift; - - my $check_type; - my $rec = $configdb->get('passwordstrength'); + + my $fm = shift; + + my $pass1 = $fm->{cgi}->param('pass'); + my $acctName = $fm->{cgi}->param('account'); + + my $check_type; + my $rec = $configdb->get('passwordstrength'); + + if (is_admin($acctName)) + $check_type = ($rec ? ($rec->prop('Admin') || 'none') : 'none'); + else $check_type = ($rec ? ($rec->prop('Users') || 'none') : 'none'); - - return $fm->validate_password($check_type,$pass1); + + return $fm->validate_password($check_type,$pass1); +} + +=pod + +=head2 is_admin + +Checks whether the user is admin or member of the so-called Domain Admins group + +=cut + +sub is_admin { + + my $fm = shift; + my $acctName = shift; + + if ($acctName eq 'admin') return 1; + + # Find possible Domain Admins group + my $adminGroup = $db->get_all_by_prop('Description' => 'Domain Admins') || ''; + + if ($adminGroup eq '') return false; + + my $members = $accountsdb->getprop($adminGroup, 'Members') || ''; + + return (",$members," =~ m/,$acctName,/); + } __DATA__