From 5df6897286ecdef161be3e04caa6c94be1fefa07 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 16 May 2006 15:18:24 +0000 Subject: [PATCH] more log messages --- lam/lib/modules.inc | 24 ++++++++++++++++++++++++ lam/templates/delete.php | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 940292d6..3e47e97c 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1310,6 +1310,8 @@ class accountContainer { * @return array list of status messages if any errors occured */ function save_account() { + $ldapUser = $_SESSION['ldap']->decrypt_login(); + $ldapUser = $ldapUser[0]; $module = array_keys ($this->module); $attributes = array(); // load attributes @@ -1382,13 +1384,19 @@ class accountContainer { } $success = ldap_add($_SESSION['ldap']->server(), $this->dn, $attr); if ($success) { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Created DN: ' . $this->dn); $success = ldap_delete($_SESSION['ldap']->server(), $this->dn_orig); if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to delete DN: ' . $this->dn_orig . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to delete DN: %s.'), $this->dn_orig), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Deleted DN: ' . $this->dn_orig); + } } if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to create DN: ' . $this->dn . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to create DN: %s.'), $this->dn), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } @@ -1401,9 +1409,13 @@ class accountContainer { if (is_array($attributes[$this->dn]['modify'])) $attr = array_merge_recursive($attr, $attributes[$this->dn]['modify']); $success = ldap_add($_SESSION['ldap']->server(), $this->dn, $attr); if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to create DN: ' . $this->dn . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to create DN: %s.'), $this->dn), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Created DN: ' . $this->dn); + } // lamdaemon commands for the new account if (!$stopprocessing) { $DN = $attributes[$this->dn]; @@ -1431,25 +1443,37 @@ class accountContainer { if (isset($attributes[$DNs[$i]]['modify']) && !$stopprocessing) { $success = @ldap_mod_replace($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['modify']); if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to modify attribtues from DN: ' . $DNs[$i] . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to modify attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Modified DN: ' . $DNs[$i]); + } } // add attributes if (isset($attributes[$DNs[$i]]['add']) && !$stopprocessing) { $success = @ldap_mod_add($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['add']); if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to add attribtues to DN: ' . $DNs[$i] . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to add attribtues to DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Modified DN: ' . $DNs[$i]); + } } // remove attributes if (isset($attributes[$DNs[$i]]['remove']) && !$stopprocessing) { $success = @ldap_mod_del($_SESSION['ldap']->server(), $DNs[$i], $attributes[$DNs[$i]]['remove']); if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to delete attribtues from DN: ' . $DNs[$i] . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $DNs[$i]), ldap_error($_SESSION['ldap']->server())); $stopprocessing = true; } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Modified DN: ' . $DNs[$i]); + } } } } diff --git a/lam/templates/delete.php b/lam/templates/delete.php index ab7d5e1d..36d8c863 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -280,9 +280,15 @@ function deleteDN($dn) { } // delete parent DN $success = @ldap_delete($_SESSION['ldap']->server(), $dn); + $ldapUser = $_SESSION['ldap']->decrypt_login(); + $ldapUser = $ldapUser[0]; if (!$success) { + logNewMessage(LOG_ERR, '[' . $ldapUser .'] Unable to delete DN: ' . $dn . ' (' . ldap_err2str(ldap_errno($_SESSION['ldap']->server())) . ').'); $errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); } + else { + logNewMessage(LOG_NOTICE, '[' . $ldapUser .'] Deleted DN: ' . $dn); + } return $errors; }