groups should be fully working now.

I hope everything is working again after a lot
of changes.
This commit is contained in:
katagia 2003-09-16 15:20:48 +00:00
parent 775aa6cf0d
commit f6614eff5a
2 changed files with 25 additions and 25 deletions

View File

@ -1628,7 +1628,7 @@ function creategroup($values) { // Will create the LDAP-Group
$attr['cn'] = $values->general_username; $attr['cn'] = $values->general_username;
$attr['gidNumber'] = $values->general_uidNumber; $attr['gidNumber'] = $values->general_uidNumber;
if ($values->general_gecos) $attr['description'] = utf8_encode($values->general_gecos); if ($values->general_gecos) $attr['description'] = utf8_encode($values->general_gecos);
if ($_SESSION['config']->samba3 =='yes' && (isset($values->smb_mapgroup))) { if ($_SESSION['config']->samba3 =='yes') {
$attr['sambaSID'] = $values->smb_mapgroup; $attr['sambaSID'] = $values->smb_mapgroup;
$attr['objectClass'][1] = 'sambaGroupMapping'; $attr['objectClass'][1] = 'sambaGroupMapping';
$attr['sambaGroupType'] = '2'; $attr['sambaGroupType'] = '2';
@ -1637,6 +1637,7 @@ function creategroup($values) { // Will create the LDAP-Group
$success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr); $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr);
if ($_SESSION['config']->scriptServer) setquotas($values,'group'); if ($_SESSION['config']->scriptServer) setquotas($values,'group');
if ($success) { if ($success) {
// Add entry to cache-array
if ((isset($_SESSION['groupDN']))) { if ((isset($_SESSION['groupDN']))) {
$_SESSION['groupDN'][$values->general_dn]['cn'] = $values->general_username; $_SESSION['groupDN'][$values->general_dn]['cn'] = $values->general_username;
$_SESSION['groupDN'][$values->general_dn]['uidNumber'] = $values->general_uidNumber; $_SESSION['groupDN'][$values->general_dn]['uidNumber'] = $values->general_uidNumber;
@ -1671,31 +1672,27 @@ function modifygroup($values,$values_old) { // Will modify the LDAP-Group
else $attr['memberUid'] = $values->unix_memberUid; else $attr['memberUid'] = $values->unix_memberUid;
} }
if ($attr_rem) {
// Add missing objectclasses to group
if (!in_array('posixGroup', $values->general_objectClass)) {
$attr['objectClass'] = $values->general_objectClass;
$attr['objectClass'][] = 'posixGroup';
}
if (($_SESSION['config']->samba3 == 'yes') && (!in_array('sambaGroupMapping', $values->general_objectClass))) {
if (!isset($attr['objectClass'])) $attr['objectClass'] = $values->general_objectClass;
$attr['objectClass'][] = 'sambaGroupMapping';
}
if ($attr_rem) { // Remove attributes not longer valid
$success = ldap_mod_del($_SESSION['ldap']->server(),$values_old->general_dn, $attr_rem); $success = ldap_mod_del($_SESSION['ldap']->server(),$values_old->general_dn, $attr_rem);
if (!$success) return 5; if (!$success) return 5;
} }
if (($_SESSION['config']->samba3 = 'yes') && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) {
$result = ldap_search($_SESSION['ldap']->server(), $values_old->general_dn, "objectclass=PosixGroup"); if ($attr) { // Add /replace new attributes
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
$attr_old = ldap_get_attributes($_SESSION['ldap']->server(), $entry);
// remove "count" from array
unset($attr_old['count']);
for ($i=0; $i < sizeof($attr_old); $i++) unset($attr_old[$i]);
$keys = array_keys($attr_old);
for ($i=0; $i < sizeof($keys); $i++)
unset($attr_old[$keys[$i]]['count']);
unset ($attr_old['objectClass']);
$attr_old['objectClass'][0] = 'posixGroup';
$attr_old['objectClass'][1] = 'sambaGroupMapping';
$success = ldap_delete($_SESSION['ldap']->server(),$values_old->general_dn);
if ($success) $success = ldap_add($_SESSION['ldap']->server(),$values->general_dn, $attr_old);
else return 5;
}
if ($attr) {
$success = ldap_modify($_SESSION['ldap']->server(),$values->general_dn, $attr); $success = ldap_modify($_SESSION['ldap']->server(),$values->general_dn, $attr);
if (!$success) return 5; if (!$success) return 5;
} }
if ($values->general_dn != $values_old->general_dn) {// Groupname hasn't changed if ($values->general_dn != $values_old->general_dn) {// Groupname hasn't changed
$result = ldap_search($_SESSION['ldap']->server(), $values_old->general_dn, "objectclass=PosixGroup"); $result = ldap_search($_SESSION['ldap']->server(), $values_old->general_dn, "objectclass=PosixGroup");
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
@ -1712,7 +1709,7 @@ function modifygroup($values,$values_old) { // Will modify the LDAP-Group
if (!$success) return 5; if (!$success) return 5;
} }
if ( $_SESSION['final_changegids']==true ) { if ( $_SESSION['final_changegids']==true ) { // Chnage GIDs of all users which are member of group
$result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), 'gidNumber=' . $values_old->general_uidNumber, array('gidNumber')); $result = ldap_search($_SESSION['ldap']->server(), $_SESSION['config']->get_UserSuffix(), 'gidNumber=' . $values_old->general_uidNumber, array('gidNumber'));
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result); $entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
while ($entry) { while ($entry) {
@ -1722,7 +1719,8 @@ function modifygroup($values,$values_old) { // Will modify the LDAP-Group
} }
} }
if ($_SESSION['config']->scriptServer) setquotas($values,'group',$values_old); if ($_SESSION['config']->scriptServer) setquotas($values,'group',$values_old);
if ((isset($_SESSION['groupDN']))) {
if ((isset($_SESSION['groupDN']))) { // refresh group-cache array
if ($values->general_dn != $values_old->general_dn) { if ($values->general_dn != $values_old->general_dn) {
unset ($_SESSION['groupDN'][$values_old->general_dn]); unset ($_SESSION['groupDN'][$values_old->general_dn]);
} }

View File

@ -530,12 +530,12 @@ switch ($select_local) { // Select which part of page will be loaded
if (isset($_SESSION['account_old']->general_objectClass)) { if (isset($_SESSION['account_old']->general_objectClass)) {
if (($_SESSION['config']->samba3 == 'yes') && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) { if (($_SESSION['config']->samba3 == 'yes') && (!in_array('sambaGroupMapping', $_SESSION['account_old']->general_objectClass))) {
echo '<tr>'; echo '<tr>';
StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to recreate entry.')); StatusMessage('WARN', _('ObjectClass sambaGroupMapping not found.'), _('Have to add objectClass sambaGroupMapping.'));
echo "</tr>\n"; echo "</tr>\n";
} }
if (!in_array('posixGroup', $_SESSION['account_old']->general_objectClass)) { if (!in_array('posixGroup', $_SESSION['account_old']->general_objectClass)) {
echo '<tr>'; echo '<tr>';
StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to recreate entry.')); StatusMessage('WARN', _('ObjectClass posixGroup not found.'), _('Have to add objectClass posixGroup.'));
echo "</tr>\n"; echo "</tr>\n";
} }
} }
@ -548,9 +548,11 @@ switch ($select_local) { // Select which part of page will be loaded
case 'finish': case 'finish':
// Final Settings // Final Settings
if (($_SESSION['config']->samba3 =='yes') && !isset($_SESSION['Account']->smb_mapgroup)) $disabled = 'disabled';
else $disabled = '';
echo '<input name="select" type="hidden" value="finish">'; echo '<input name="select" type="hidden" value="finish">';
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>"._('Success')."</b></legend>\n"; echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>"._('Success')."</b></legend>\n";
echo "<table border=0 width=\"100%\"><tr><td>"; echo "<table border=0 width=\"100%\">";
echo '<tr><td>'; echo '<tr><td>';
echo _('Group').' '; echo _('Group').' ';
echo $_SESSION['account']->general_username; echo $_SESSION['account']->general_username;