SiT! Bugs - SiT!
View Issue Details
0001424SiT!LDAPpublic2010-12-05 03:342013-07-06 17:15
johng 
paulh 
normalminorsometimes
resolvedfixed 
3.62 LTS 
3.68Current SVN 
0001424: LDAP service tries to disable a customer who is already disabled and fails
If a customer account in LDAP is disabled, SIT will try to repeatedly disable the account.
patch
duplicate of 0001399closed paulh ldap_logindisabledattribute produces call of non-object in auto.php 
related to 0001843resolved paulh LDAP-Sync: Disabling of contacts fails 
Issue History
2010-12-05 03:34johngNew Issue
2010-12-05 03:35johngNote Added: 0003498
2011-02-10 09:46ivanTag Attached: patch
2011-02-10 09:46ivanNote Added: 0003563
2011-02-10 09:46ivanStatusnew => acknowledged
2011-02-10 09:59paulhRelationship addedduplicate of 0001399
2011-02-10 09:59paulhNote Added: 0003564
2011-02-14 21:33paulhAssigned To => paulh
2011-02-14 21:33paulhStatusacknowledged => assigned
2011-02-14 21:33paulhNote Added: 0003603
2013-03-01 19:48paulhRelationship addedrelated to 0001843
2013-03-02 13:19paulhNote Added: 0004726
2013-03-02 13:19paulhStatusassigned => resolved
2013-03-02 13:19paulhResolutionopen => fixed
2013-03-02 13:19paulhFixed in Version => Current SVN
2013-07-06 17:15ivanTarget Version => 3.68

Notes
(0003498)
johng   
2010-12-05 03:35   
Solution:

# svn diff *
Index: auto.php
===================================================================
--- auto.php (revision 7)
+++ auto.php (working copy)
@@ -944,7 +944,9 @@
                                 if (strtolower($contact_attributes[$CONFIG['ldap_logindisabledattribute']][0]) == strtolower($CONFIG['ldap_logindisabledvalue']))
                                 {
                                     // We want to disable
- $sit_db_contacts[$contact_attributes[$CONFIG['ldap_userattribute']][0]]->disable();
+ if ($sit_db_contacts[$contact_attributes[$CONFIG['ldap_userattribute']][0]]) {
+ $sit_db_contacts[$contact_attributes[$CONFIG['ldap_userattribute']][0]]->disable();
+ }
                                 }
                             }
                         }
@@ -968,7 +970,7 @@
                 // TODO reassign incidents?
                 foreach ($sit_db_contacts AS $c)
                 {
- debug_log ("Disabling {$c->username}", TRUE);
+ debug_log ("Disabling {$c->username} because they don't exist in LDAP", TRUE);
                     $c->disable();
                 }
             }
Index: lib/classes.inc.php
===================================================================
--- lib/classes.inc.php (revision 7)
+++ lib/classes.inc.php (working copy)
@@ -491,19 +495,24 @@
         $toReturn = true;
         if (!empty($this->id))
         {
- $sql = "UPDATE `{$GLOBALS['dbContacts']}` SET active = 'false' WHERE id = {$this->id}";
-
- $result = mysql_query($sql);
- if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
- if (mysql_affected_rows() != 1)
- {
- trigger_error("Failed to disable contact {$this->username}", E_USER_WARNING);
- $toReturn = false;
- }
- else
- {
- $toReturn = true;
- }
+ $sql = "SELECT 1 FROM `{$GLOBALS['dbContacts']}` WHERE id = {$this->id} AND active = 'false'";
+ $result = mysql_query($sql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ if (mysql_fetch_array($result,MYSQL_NUM)) {
+ debug_log("Failed to disable contact {$this->username}, was already disabled");
+ }
+ else
+ {
+ $sql = "UPDATE `{$GLOBALS['dbContacts']}` SET active = 'false' WHERE id = {$this->id}";
+
+ $result = mysql_query($sql);
+ if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
+ if (mysql_affected_rows() != 1)
+ {
+ trigger_error("Failed to disable contact {$this->username}", E_USER_WARNING);
+ $toReturn = false;
+ }
+ }
         }

         return $toReturn;
(0003563)
ivan   
2011-02-10 09:46   
Thanks johng
(0003564)
paulh   
2011-02-10 09:59   
Looks like I merged some of this patch in http://gitorious.org/sit/paulheaneys-sit/commit/b0c685f [^] (see linked bug)
(0003603)
paulh   
2011-02-14 21:33   
Confirm second issue about sync task becoming disabled
(0004726)
paulh   
2013-03-02 13:19   
current svn resolves this, see associated bugs