Skip to content

Commit

Permalink
Improve comment before ldap_connect_bind() call
Browse files Browse the repository at this point in the history
Explain why
- we suppress errors in ldap_cache_user_data()
- it's useless to check for failures in ldap_authenticate_by_username()
  • Loading branch information
dregad committed Jan 27, 2020
1 parent 212d183 commit 6e63077
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/ldap_api.php
Expand Up @@ -211,7 +211,9 @@ function ldap_cache_user_data( $p_username ) {

log_event( LOG_LDAP, "Retrieving data for '$p_username' from LDAP server" );

# Bind
# Bind and connect.
# We suppress errors, because failing to connect is not blocking in this
# context, it just means we won't be able to retrieve user data from LDAP.
$t_ds = @ldap_connect_bind();
if( $t_ds === false ) {
log_event( LOG_LDAP, "ERROR: could not bind to LDAP server" );
Expand Down Expand Up @@ -335,7 +337,9 @@ function ldap_authenticate_by_username( $p_username, $p_password ) {
'dn',
);

# Bind
# Bind and connect.
# No need to check for failures, as ldap_connect_bind() throws errors.
log_event( LOG_LDAP, 'Binding to LDAP server' );
$t_ds = ldap_connect_bind();

# Search for the user id
Expand Down

0 comments on commit 6e63077

Please sign in to comment.