Skip to content

Commit

Permalink
Implement ServerConnectFailed exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Jan 15, 2012
1 parent 44cc64d commit 1ece61d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 13 additions & 0 deletions application/MantisBT/Exception/LDAP/ServerConnectFailed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace MantisBT\Exception\LDAP;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class ServerConnectFailed extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_LDAP_SERVER_CONNECT_FAILED, null, false);
parent::__construct(ERROR_LDAP_SERVER_CONNECT_FAILED, $errorMessage, null);
$this->responseCode = 500;
}
}
7 changes: 4 additions & 3 deletions application/core/ldap_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/

use MantisBT\Exception\LDAP\ExtensionNotLoaded;
use MantisBT\Exception\LDAP\ServerConnectFailed;

require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
Expand Down Expand Up @@ -101,13 +102,13 @@ function ldap_connect_bind( $p_binddn = '', $p_password = '' ) {
if ( !$t_br ) {
ldap_log_error( $t_ds );
log_event( LOG_LDAP, "Bind to ldap server failed" );
trigger_error( ERROR_LDAP_SERVER_CONNECT_FAILED, ERROR );
throw new ServerConnectFailed();
} else {
log_event( LOG_LDAP, "Bind to ldap server successful" );
}
} else {
log_event( LOG_LDAP, "Connection to ldap server failed" );
trigger_error( ERROR_LDAP_SERVER_CONNECT_FAILED, ERROR );
throw new ServerConnectFailed();
}

return $t_ds;
Expand Down Expand Up @@ -412,7 +413,7 @@ function ldap_simulation_get_user( $p_username ) {
$t_lines = file( $t_filename );
if ( $t_lines === false ) {
log_event( LOG_LDAP, "ldap_simulation_get_user: could not read simulation data from $t_filename." );
trigger_error( ERROR_LDAP_SERVER_CONNECT_FAILED, ERROR );
throw new ServerConnectFailed();
}

foreach ( $t_lines as $t_line ) {
Expand Down

0 comments on commit 1ece61d

Please sign in to comment.