Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make AD configurations ignore ldap_auth_filter_query #11319

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/Models/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static function findAndBindUserLdap($username, $password)
$ldap_username_field = $settings->ldap_username_field;
$baseDn = $settings->ldap_basedn;
$userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn;
$filterQuery = '';

if ($settings->is_ad == '1') {
// Check if they are using the userprincipalname for the username field.
Expand All @@ -111,9 +112,18 @@ public static function findAndBindUserLdap($username, $password)
// Hopefully that should handle all of our use cases, but if not we can backport our old logic.
$userDn = ($settings->ad_domain != '') ? $username.'@'.$settings->ad_domain : $username.'@'.$settings->email_domain;
}
// Note: AD completely **ignores** the ldap_auth_filter_query!
// it just does a simple query for whatever the username field is equalling whatever the username is
// typically samaccountname=shortname or userprincipalname=shortname@domain.com
// I kinda don't like this because it feels far more limited relative to a full LDAP configuration
// and if you wanted to do something funky or clever with AD - you can't.
$filterQuery = $ldap_username_field."=".$username;
} else {
// non-LDAP auth query is the auth filter, with the username appended
// e.g. filter query of 'uid=' and username of 'brady' becomes:
// uid=brady
$filterQuery = $settings->ldap_auth_filter_query.$username;
}

$filterQuery = $settings->ldap_auth_filter_query.$username;
$filter = Setting::getSettings()->ldap_filter; //FIXME - this *does* respect the ldap filter, but I believe that AdLdap2 did *not*.
$filterQuery = "({$filter}({$filterQuery}))";

Expand Down