Skip to content

Commit

Permalink
Fix for broken JSON response when group id is binary
Browse files Browse the repository at this point in the history
changed placeholder in ldap_groups_roles queries to reflect the non-integer value
  • Loading branch information
simonpoess committed May 15, 2024
1 parent f851d99 commit a27ce87
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sources/identify.php
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ function handleUserADGroups(string $username, array $userInfo, array $groups, ar
$role = DB::queryFirstRow(
'SELECT lgr.role_id
FROM ' . prefixTable('ldap_groups_roles') . ' AS lgr
WHERE lgr.ldap_group_id = %i',
WHERE lgr.ldap_group_id = %s',
$group
);
if (DB::count() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion sources/roles.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@
'SELECT a.increment_id as increment_id, a.role_id as role_id, r.title as title
FROM '.prefixTable('ldap_groups_roles').' AS a
INNER JOIN '.prefixTable('roles_title').' AS r ON r.id = a.role_id
WHERE a.ldap_group_id = %i',
WHERE a.ldap_group_id = %s',
$key
);
$counter = DB::count();
Expand Down
4 changes: 2 additions & 2 deletions vendor/teampassclasses/ldapextra/src/ActiveDirectoryExtra.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getADGroups(Connection $connection, array $settings): array

$groupsArr = [];
foreach($groups as $key => $group) {
$adGroupId = (int) $group[(isset($settings['ldap_guid_attibute']) === true && empty($settings['ldap_guid_attibute']) === false ? $settings['ldap_guid_attibute'] : 'gidnumber')][0];
$adGroupId = md5($group[(isset($settings['ldap_guid_attibute']) === true && empty($settings['ldap_guid_attibute']) === false ? $settings['ldap_guid_attibute'] : 'gidnumber')][0]);
$groupsArr[$adGroupId] = [
'ad_group_id' => $adGroupId,
'ad_group_title' => $group['cn'][0],
Expand Down Expand Up @@ -113,7 +113,7 @@ function getUserADGroups(string $userDN, Connection $connection, array $SETTINGS
foreach ($groups as $group) {
array_push(
$groupsArr,
$group[$idAttribute][0]
md5($group[$idAttribute][0])
);
}
} catch (\LdapRecord\Auth\BindException $e) {
Expand Down

0 comments on commit a27ce87

Please sign in to comment.