TASK-289 Show attributes and filter in searh AD LDAP
This commit is contained in:
Binary file not shown.
@@ -336,7 +336,14 @@ class AuthSources
|
|||||||
$arrayData[] = $listUsersData;
|
$arrayData[] = $listUsersData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['success' => true, 'status' => 'OK', 'resultTotal' => $result['numRecTotal'], 'resultRoot' => $arrayData];
|
$response = [
|
||||||
|
'success' => true,
|
||||||
|
'status' => 'OK',
|
||||||
|
'resultTotal' => $result['numRecTotal'],
|
||||||
|
'resultRoot' => $arrayData,
|
||||||
|
'context' => $result['context']
|
||||||
|
];
|
||||||
|
return $response;
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
return ['success' => false, 'message' => $exception->getMessage()];
|
return ['success' => false, 'message' => $exception->getMessage()];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class LdapSource
|
|||||||
|
|
||||||
$ldapcnn = ldap_connect($authSourceData['AUTH_SOURCE_SERVER_NAME'], $authSourceData['AUTH_SOURCE_PORT']);
|
$ldapcnn = ldap_connect($authSourceData['AUTH_SOURCE_SERVER_NAME'], $authSourceData['AUTH_SOURCE_PORT']);
|
||||||
$this->stdLog($ldapcnn, 'ldap_connect', $loggableAuthSource);
|
$this->stdLog($ldapcnn, 'ldap_connect', $loggableAuthSource);
|
||||||
|
|
||||||
$ldapServer = $authSourceData['AUTH_SOURCE_SERVER_NAME'] . ':' . $authSourceData['AUTH_SOURCE_PORT'];
|
$ldapServer = $authSourceData['AUTH_SOURCE_SERVER_NAME'] . ':' . $authSourceData['AUTH_SOURCE_PORT'];
|
||||||
|
|
||||||
ldap_set_option($ldapcnn, LDAP_OPT_PROTOCOL_VERSION, 3);
|
ldap_set_option($ldapcnn, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
@@ -64,7 +65,6 @@ class LdapSource
|
|||||||
$bBind = ldap_bind($ldapcnn, $authSourceData['AUTH_SOURCE_SEARCH_USER'], $authSourceData['AUTH_SOURCE_PASSWORD']);
|
$bBind = ldap_bind($ldapcnn, $authSourceData['AUTH_SOURCE_SEARCH_USER'], $authSourceData['AUTH_SOURCE_PASSWORD']);
|
||||||
$this->log($ldapcnn, 'bind ' . $ldapServer . ' with user ' . $loggableAuthSource['AUTH_SOURCE_SEARCH_USER']);
|
$this->log($ldapcnn, 'bind ' . $ldapServer . ' with user ' . $loggableAuthSource['AUTH_SOURCE_SEARCH_USER']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->stdLog($ldapcnn, 'ldap_bind', $loggableAuthSource);
|
$this->stdLog($ldapcnn, 'ldap_bind', $loggableAuthSource);
|
||||||
$this->getDiagnosticMessage($ldapcnn);
|
$this->getDiagnosticMessage($ldapcnn);
|
||||||
if (!$bBind) {
|
if (!$bBind) {
|
||||||
@@ -480,7 +480,9 @@ class LdapSource
|
|||||||
$uidUserIdentifier = (isset($arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER'])) ? $arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER'] : 'uid';
|
$uidUserIdentifier = (isset($arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER'])) ? $arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER'] : 'uid';
|
||||||
$filterUsers = trim($arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_USERS_FILTER']);
|
$filterUsers = trim($arrayAuthenticationSourceData['AUTH_SOURCE_DATA']['AUTH_SOURCE_USERS_FILTER']);
|
||||||
$filter = ($filterUsers != '') ? $filterUsers : '(' . $this->arrayObjectClassFilter['user'] . ')';
|
$filter = ($filterUsers != '') ? $filterUsers : '(' . $this->arrayObjectClassFilter['user'] . ')';
|
||||||
$filter = "(&$filter(|(dn=$keyword)(uid=$keyword)(samaccountname=$keyword)(givenname=$keyword)(sn=$keyword)(cn=$keyword)(mail=$keyword)(userprincipalname=$keyword)))";
|
$filtersDefault = "(|(dn=$keyword)(uid=$keyword)(samaccountname=$keyword)(givenname=$keyword)(sn=$keyword)(cn=$keyword)(mail=$keyword)(userprincipalname=$keyword))";
|
||||||
|
$filter = '(&' . $filter . $filtersDefault . ')';
|
||||||
|
|
||||||
$oSearch = @ldap_search($ldapcnn, $arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'], $filter, array_merge($this->arrayAttributesForUser, $attributeSetAdd));
|
$oSearch = @ldap_search($ldapcnn, $arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'], $filter, array_merge($this->arrayAttributesForUser, $attributeSetAdd));
|
||||||
$context = [
|
$context = [
|
||||||
'baseDN' => $arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
'baseDN' => $arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN'],
|
||||||
@@ -562,7 +564,12 @@ class LdapSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ($paged) ? ['numRecTotal' => $totalUser, 'data' => $arrayUser] : $arrayUser;
|
$response = [
|
||||||
|
'numRecTotal' => $totalUser,
|
||||||
|
'data' => $arrayUser,
|
||||||
|
'context' => $context
|
||||||
|
];
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getUserDataFromAttribute($username, array $arrayAttributes)
|
private function getUserDataFromAttribute($username, array $arrayAttributes)
|
||||||
@@ -578,7 +585,9 @@ class LdapSource
|
|||||||
'sLastname' => trim((isset($arrayAttributes['sn'])) ? ((is_array($arrayAttributes['sn'])) ? $arrayAttributes['sn'][0] : $arrayAttributes['sn']) : ''),
|
'sLastname' => trim((isset($arrayAttributes['sn'])) ? ((is_array($arrayAttributes['sn'])) ? $arrayAttributes['sn'][0] : $arrayAttributes['sn']) : ''),
|
||||||
'sEmail' => trim((isset($arrayAttributes[$keyMail])) ? ((is_array($arrayAttributes[$keyMail])) ? $arrayAttributes[$keyMail][0] : $arrayAttributes[$keyMail]) : ''),
|
'sEmail' => trim((isset($arrayAttributes[$keyMail])) ? ((is_array($arrayAttributes[$keyMail])) ? $arrayAttributes[$keyMail][0] : $arrayAttributes[$keyMail]) : ''),
|
||||||
'sDN' => trim($arrayAttributes['dn']),
|
'sDN' => trim($arrayAttributes['dn']),
|
||||||
'sManagerDN' => trim((isset($arrayAttributes['manager'])) ? ((is_array($arrayAttributes['manager'])) ? $arrayAttributes['manager'][0] : $arrayAttributes['manager']) : '')
|
'sManagerDN' => trim((isset($arrayAttributes['manager'])) ? ((is_array($arrayAttributes['manager'])) ? $arrayAttributes['manager'][0] : $arrayAttributes['manager']) : ''),
|
||||||
|
// TODO REMOVE THIS LAST INDEX, ONLY FOR REVIEW
|
||||||
|
'allAttributes' => (array)$arrayAttributes
|
||||||
];
|
];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|||||||
Reference in New Issue
Block a user