better error handling
This commit is contained in:
parent
e59f8d20f2
commit
0fabae9c2e
|
@ -816,8 +816,8 @@ class accountContainer {
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($this->subpage=='') $this->subpage='attributes';
|
if ($this->subpage=='') $this->subpage='attributes';
|
||||||
if (isset($_POST['form_main_reset'])) {
|
if (isset($_POST['form_main_reset'])) {
|
||||||
$this->load_account($this->dn_orig);
|
$result = $this->load_account($this->dn_orig);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($this->current_page==0) {
|
if ($this->current_page==0) {
|
||||||
if ($this->subpage=='attributes') {
|
if ($this->subpage=='attributes') {
|
||||||
|
@ -1172,12 +1172,20 @@ class accountContainer {
|
||||||
* Loads an LDAP account with the given DN.
|
* Loads an LDAP account with the given DN.
|
||||||
*
|
*
|
||||||
* @param string $dn the DN of the account
|
* @param string $dn the DN of the account
|
||||||
|
* @return array error messages
|
||||||
*/
|
*/
|
||||||
function load_account($dn) {
|
function load_account($dn) {
|
||||||
|
$this->module = array();
|
||||||
$modules = $_SESSION['config']->get_AccountModules($this->type);
|
$modules = $_SESSION['config']->get_AccountModules($this->type);
|
||||||
$search = substr($dn, 0, strpos($dn, ','));
|
$search = substr($dn, 0, strpos($dn, ','));
|
||||||
$result = ldap_search($_SESSION['ldap']->server(), $dn, $search);
|
$result = @ldap_search($_SESSION['ldap']->server(), $dn, $search);
|
||||||
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
|
if (!$result) {
|
||||||
|
return array(array("ERROR", _("Unable to load LDAP entry: ") . $dn, ldap_error($_SESSION['ldap']->server())));
|
||||||
|
}
|
||||||
|
$entry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||||
|
if (!$entry) {
|
||||||
|
return array(array("ERROR", _("Unable to load LDAP entry: ") . $dn, ldap_error($_SESSION['ldap']->server())));
|
||||||
|
}
|
||||||
$this->dn = substr($dn, strpos($dn, ',')+1);
|
$this->dn = substr($dn, strpos($dn, ',')+1);
|
||||||
$this->dn_orig = $dn;
|
$this->dn_orig = $dn;
|
||||||
// extract RDN
|
// extract RDN
|
||||||
|
@ -1215,7 +1223,7 @@ class accountContainer {
|
||||||
|
|
||||||
// sort module buttons
|
// sort module buttons
|
||||||
$this->sortModules();
|
$this->sortModules();
|
||||||
return 0;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,19 @@ if (isset($_GET['DN'])) {
|
||||||
if ($_GET['type'] == $type) $type = str_replace("'", '',$_GET['type']);
|
if ($_GET['type'] == $type) $type = str_replace("'", '',$_GET['type']);
|
||||||
if ($_GET['DN'] == $DN) $DN = str_replace("'", '',$_GET['DN']);
|
if ($_GET['DN'] == $DN) $DN = str_replace("'", '',$_GET['DN']);
|
||||||
$_SESSION['account'] = new accountContainer($type, 'account');
|
$_SESSION['account'] = new accountContainer($type, 'account');
|
||||||
$_SESSION['account']->load_account($DN);
|
$result = $_SESSION['account']->load_account($DN);
|
||||||
|
if (sizeof($result) > 0) {
|
||||||
|
echo $_SESSION['header'];
|
||||||
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
||||||
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $type . ".css\">\n";
|
||||||
|
echo "</head><body>\n";
|
||||||
|
for ($i=0; $i<sizeof($result); $i++) {
|
||||||
|
call_user_func_array("StatusMessage", $result[$i]);
|
||||||
|
}
|
||||||
|
echo "</body>\n";
|
||||||
|
echo "</html>\n";
|
||||||
|
die();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// new account
|
// new account
|
||||||
else if (count($_POST)==0) {
|
else if (count($_POST)==0) {
|
||||||
|
|
Loading…
Reference in New Issue