diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 701ba86f..7b7c2164 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -823,7 +823,7 @@ function createuser($values) { // Will create the LDAP-Account if ($values->smb_pwdmustchange!='') $attr['pwdMustChange'] = $values->smb_pwdmustchange; // sambaAccount_may else $attr['pwdMustChange'] = time() + 1000000000; // sambaAccount_may $attr['pwdMustChange'] = $values->smb_pwdmustchange; // sambaAccount_may - $attr['acctFlags'] = smbflag(values); // sambaAccount_may + $attr['acctFlags'] = smbflag($values); // sambaAccount_may $attr['displayName'] = $values->general_gecos; // sambaAccount_may if ($values->smb_smbhome!='') $attr['smbHome'] = utf8_encode($values->smb_smbhome); // sambaAccount_may if ($values->smb_homedrive!='') $attr['homeDrive'] = $values->smb_homedrive; // sambaAccount_may @@ -877,7 +877,7 @@ function createuser($values) { // Will create the LDAP-Account $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr); if (!$success) return 4; if ($_SESSION['config']->scriptServer) { - setquotas($values,'user'); + if (is_array($values->quota)) setquotas($values,'user'); addhomedir($values->general_username); } // Add User to Additional Groups @@ -999,7 +999,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account } if ($values->smb_pwdcanchange != $values_old->smb_pwdcanchange) $attr['sambaPwdCanChange'] = $values->smb_pwdcanchange; // sambaAccount_may if ($values->smb_pwdmustchange != $values_old->smb_pwdmustchange) $attr['sambaPwdMustChange'] = $values->smb_pwdmustchange; // sambaAccount_may - $attr['sambaAcctFlags'] = smbflag($values); // sambaAccount_may + if (smbflag($values) != smbflag($values_old)) $attr['sambaAcctFlags'] = smbflag($values); // sambaAccount_may if (($values->smb_smbhome!='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr['sambaHomePath'] = utf8_encode($values->smb_smbhome); // sambaAccount_may if (($values->smb_smbhome=='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr_rem['sambaHomePath'] = utf8_encode($values_old->smb_smbhome); // sambaAccount_may if (($values->smb_homedrive!='') && ($values->smb_homedrive!=$values_old->smb_homedrive)) $attr['sambaHomeDrive'] = $values->smb_homedrive; // sambaAccount_may @@ -1030,7 +1030,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account } if ($values->smb_pwdcanchange != $values_old->smb_pwdcanchange) $attr['pwdCanChange'] = $values->smb_pwdcanchange; // sambaAccount_may if ($values->smb_pwdmustchange != $values_old->smb_pwdmustchange) $attr['pwdMustChange'] = $values->smb_pwdmustchange; // sambaAccount_may - $attr['acctFlags'] = smbflag($values); // sambaAccount_may + if (smbflag($values) != smbflag($values_old)) $attr['acctFlags'] = smbflag($values); // sambaAccount_may if (($values->smb_smbhome!='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr['smbHome'] = utf8_encode($values->smb_smbhome); // sambaAccount_may if (($values->smb_smbhome=='') && ($values->smb_smbhome!=$values_old->smb_smbhome)) $attr_rem['smbHome'] = utf8_encode($values_old->smb_smbhome); // sambaAccount_may if (($values->smb_homedrive!='') && ($values->smb_homedrive!=$values_old->smb_homedrive)) $attr['homeDrive'] = $values->smb_homedrive; // sambaAccount_may @@ -1298,7 +1298,7 @@ function modifyuser($values,$values_old) { // Will modify the LDAP-Account } $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); } - if ($_SESSION['config']->scriptServer) setquotas($values,'user',$values_old); + if ($_SESSION['config']->scriptServer && is_array($values->quota) ) setquotas($values,'user',$values_old); if ((isset($_SESSION['userDN']))) { if ($values->general_dn != $values_old->general_dn) { unset ($_SESSION['userDN'][$values_old->general_dn]); @@ -1409,8 +1409,6 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account } } - - if ($values->smb_flagsD != $values_old->smb_flagsD) { $i = 0; while ($values_old->unix_password{$i} != '}') $i++; @@ -1555,7 +1553,7 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account $attr['userPassword'] = ''; $attr['shadowLastChange'] = getdays(); } - $attr['sambaAcctFlags'] = smbflag($values); // sambaAccount_may + if (smbflag($values) != smbflag($values_old)) $attr['sambaAcctFlags'] = smbflag($values); // sambaAccount_may if ($values->smb_domain->name!=$values_old->smb_domain->name) $attr['sambaDomainName'] = $values->smb_domain->name; // sambaAccount_may } // samba 2.2 @@ -1568,7 +1566,7 @@ function modifyhost($values,$values_old) { // Will modify the LDAP-Account $attr['shadowLastChange'] = getdays(); } if (isset($attr_old['sambaSID'][0])) $attr_rem['sambaSID'] = $attr_old['sambaSID'][0]; - $attr['acctFlags'] = smbflag($values); // sambaAccount_may + if (smbflag($values) != smbflag($values_old)) $attr['acctFlags'] = smbflag($values); // sambaAccount_may if (($values->smb_domain!='') && ($values->smb_domain!=$values_old->smb_domain)) $attr['domain'] = $values->smb_domain; // sambaAccount_may if (($values->smb_domain=='') && ($values->smb_domain!=$values_old->smb_domain)) $attr_rem['domain'] = $values_old->smb_domain; // sambaAccount_may } @@ -1634,7 +1632,7 @@ function creategroup($values) { // Will create the LDAP-Group $attr['memberUid'][] = $user; $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr); if (!$success) return 4; - if ($_SESSION['config']->scriptServer) setquotas($values,'group'); + if ($_SESSION['config']->scriptServer && is_array($values->quota)) setquotas($values,'group'); // Add entry to cache-array if ((isset($_SESSION['groupDN']))) { $_SESSION['groupDN'][$values->general_dn]['cn'] = $values->general_username; @@ -1715,12 +1713,12 @@ function modifygroup($values,$values_old) { // Will modify the LDAP-Group $entry = ldap_first_entry($_SESSION['ldap']->server(), $result); while ($entry) { $user['gidNumber'][0] = $values->general_uidNumber; - ldap_modify($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $user); + $success =ldap_modify($_SESSION['ldap']->server(), ldap_get_dn($_SESSION['ldap']->server(), $entry), $user); $entry = ldap_next_entry($_SESSION['ldap']->server(), $entry); } } - if ($_SESSION['config']->scriptServer) setquotas($values,'group',$values_old); - + if (!$success) return 5; + if ($_SESSION['config']->scriptServer && is_array($values->quota)) setquotas($values,'group',$values_old); if ((isset($_SESSION['groupDN']))) { // refresh group-cache array if ($values->general_dn != $values_old->general_dn) { unset ($_SESSION['groupDN'][$values_old->general_dn]); diff --git a/lam/templates/account/groupedit.php b/lam/templates/account/groupedit.php index e1780927..68823529 100644 --- a/lam/templates/account/groupedit.php +++ b/lam/templates/account/groupedit.php @@ -407,6 +407,7 @@ switch ($select_local) { // Select which part of page will be loaded unset($temp2[0]); foreach ($temp2 as $temp) $users[] = $temp['cn']; sort($users, SORT_STRING); + $users = array_delete($account_new->unix_memberUid, $users); echo "\n"; echo "\n'."\n".''."\n".''."\n".''."\n".''."\n".''."\n".'
"; echo "\n
"; diff --git a/lam/templates/account/useredit.php b/lam/templates/account/useredit.php index 6f522bc8..0dcdf6ed 100644 --- a/lam/templates/account/useredit.php +++ b/lam/templates/account/useredit.php @@ -52,6 +52,7 @@ $ldap_intern =& $_SESSION['ldap']; $config_intern =& $_SESSION['config']; $header_intern =& $_SESSION['header']; $hostDN_intern =& $_SESSION['hostDN']; +$groupDN_intern =& $_SESSION['groupDN']; @@ -122,6 +123,28 @@ switch ($_POST['select']) { // Select which part of page should be loaded and ch // if account is modified commands might be ran are shown // finish = page shown after account has been created/modified + case 'groups': + do { // X-Or, only one if() can be true + if (isset($_POST['allgroups']) && isset($_POST['add'])) { // Add users to list + // Add new user + $account_new->general_groupadd = array_merge($account_new->general_groupadd, $_POST['allgroups']); + // remove doubles + $account_new->general_groupadd = array_flip($account_new->general_groupadd); + array_unique($account_new->general_groupadd); + $account_new->general_groupadd = array_flip($account_new->general_groupadd); + // sort user + sort($account_new->general_groupadd); + // display groupmembers page + break; + } + if (isset($_POST['selectedgroups']) && isset($_POST['remove'])) { // remove users fromlist + $account_new->general_groupadd = array_delete($_POST['selectedgroups'], $account_new->general_groupadd); + break; + } + } while(0); + $select_local = 'groups'; + break; + case 'workstations': do { // X-Or, only one if() can be true if (isset($_POST['hosts']) && isset($_POST['add'])) { // Add users to list @@ -505,6 +528,11 @@ do { // X-Or, only one if() can be true else $select_local=$_POST['select']; break; } + if ($_POST['next_groups']) { + if (!is_array($errors)) $select_local='groups'; + else $select_local=$_POST['select']; + break; + } if ($_POST['next_reset']) { $account_new = $account_old; $account_new->unix_password=''; @@ -651,11 +679,12 @@ switch ($select_local) { // Select which part of page will be loaded ldapreload('host'); $temp2 = $hostDN_intern; unset($temp2[0]); - foreach ($temp2 as $temp) $hosts[] = $temp['cn']; + foreach ($temp2 as $temp) $hosts[] = str_replace("$", '',$temp['cn']); sort($hosts, SORT_STRING); // get workstation array $temp = str_replace(' ', '', $account_new->smb_smbuserworkstations); $workstations = explode (',', $temp); + $hosts = array_delete($workstations, $hosts); echo ''; echo "\n
"; echo "\n\n
"; @@ -700,14 +729,74 @@ switch ($select_local) { // Select which part of page will be loaded echo "\n"; if (count($hosts)!=0) { echo "\n"; + } + echo "
\n"; + echo "\n"; + echo "
\n
\n"; + break; + + case 'groups': + ldapreload('group'); + $temp2 = $groupDN_intern; + unset($temp2[0]); + foreach ($temp2 as $temp) $groups[] = $temp['cn']; + sort($groups, SORT_STRING); + $groups = array_delete($account_new->general_groupadd, $groups); + + echo ''; + echo "\n\n\n
"; + echo "
"; + echo _('Please select page:'); + echo "\n"; + echo "\n
"; + echo "\n
"; + echo "\n
"; + echo "scriptPath)) echo " disabled "; + echo "value=\""; echo _('Quota'); echo "\">\n
"; + echo "\n
"; + echo ""; + if (isset($account_old)) { + echo "

"; + echo _("Reset all changes."); + echo "
"; + echo "\n"; + } + echo "
"; + echo "\n\n
"; + echo "
"; + echo _("Additional groups"); + echo "\n\n\n\n"; + echo "\n"; + echo "\n\n
"; + echo "
"; + echo _("Selected groups"); + echo "\n"; + if (count($account_new->general_groupadd)!=0) { + echo "\n"; + } + echo "
"; + echo " "; + echo "\">

"; + echo ""._('Help-XX')."
"; + echo _('Available groups'); + echo "\n"; + if (count($groups)!=0) { + echo "\n"; } echo "
\n"; - echo "\n"; + echo "\n"; echo "
\n
\n"; break; @@ -778,17 +867,10 @@ switch ($select_local) { // Select which part of page will be loaded echo '
'. ''._('Help').''. '
'; + echo _('Additional groups'); - echo ''. + echo ''. + ''. ''._('Help').''. '
'; echo _('Home directory').'*';