Skip to content

Commit

Permalink
Fix PHP warning when ldap_connect_bind() fails
Browse files Browse the repository at this point in the history
ldap_errno() / ldap_error() expect a resource, but the link identifier
is `false`.

- ldap_cache_user_data(): replace ldap_log_error() by a generic
  log_event() call
- ldap_authenticate_by_username(): remove the whole if statement, which
  is useless as ldap_connect_bind() will throw an error that will halt
  program execution if the connection fails.

Fixes #26629
  • Loading branch information
dregad committed Jan 27, 2020
1 parent f91d60a commit 212d183
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions core/ldap_api.php
Expand Up @@ -214,7 +214,7 @@ function ldap_cache_user_data( $p_username ) {
# Bind
$t_ds = @ldap_connect_bind();
if( $t_ds === false ) {
ldap_log_error( $t_ds );
log_event( LOG_LDAP, "ERROR: could not bind to LDAP server" );
return false;
}

Expand Down Expand Up @@ -337,10 +337,6 @@ function ldap_authenticate_by_username( $p_username, $p_password ) {

# Bind
$t_ds = ldap_connect_bind();
if( $t_ds === false ) {
ldap_log_error( $t_ds );
trigger_error( ERROR_LDAP_AUTH_FAILED, ERROR );
}

# Search for the user id
log_event( LOG_LDAP, 'Searching for ' . $t_search_filter );
Expand Down

0 comments on commit 212d183

Please sign in to comment.