From b525a12b0d4d494bc7f0218fd7d0798d71699140 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 15 Feb 2008 13:25:34 +0000 Subject: [PATCH] Added Check that displays a warning if a duplicated uidNumber was written. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8931 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/posix/class_posixAccount.inc | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc index 0fb23e5a4..04d61596f 100644 --- a/gosa-core/plugins/personal/posix/class_posixAccount.inc +++ b/gosa-core/plugins/personal/posix/class_posixAccount.inc @@ -885,6 +885,18 @@ class posixAccount extends plugin /* Save data to LDAP */ $ldap->cd($this->dn); $this->cleanup(); + + /* This is just a test, we have had duplicated ids + in the past when copy & paste was used. + Normaly this should not happen. + */ + if(isset($this->attrs['uidNumber']) && !$this->force_ids){ + $used = $this->get_used_uid_numbers(); + if(isset($used[$this->attrs['uidNumber']]) && $used[$this->attrs['uidNumber']] != $this->dn){ + msg_dialog::display(_("Uid number"),_("A duplicated uid number was written for this user, if this was not intended please verify all used uidNumbers."), WARNING_DIALOG); + } + } + unset($this->attrs['uid']); $ldap->modify ($this->attrs); @@ -1222,6 +1234,22 @@ class posixAccount extends plugin } + function get_used_uid_numbers() + { + $ids= array(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd ($this->config->current['BASE']); + $ldap->search ("(&(objectClass=posixAccount)(uidNumber=*))", array("uidNumber")); + + /* Get list of ids */ + while ($attrs= $ldap->fetch()){ + $ids[$attrs['uidNumber'][0]] = $attrs['dn']; + } + return($ids); + } + + function get_next_id($attrib, $dn) { $ids= array(); -- 2.30.2