-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
44 lines (33 loc) · 1.69 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php // -*-PHP-*-
require_once ('lib/groups.inc.php');
require_once ('lib/supannPerson.inc.php');
if (GET_bool("CAS")) forceCASAuthentication();
$token = GET_ldapFilterSafe("token");
$user_attrs = GET_or_NULL("user_attrs");
$group_attrs = explode(',', GET_or_NULL("group_attrs"));
$maxRows = GET_uid() ? GET_or("maxRows", 0) : min(max(1, GET_or_NULL("maxRows")), 10);
$kinds = explode(',', GET_or("kinds", "users,groups"));
$restriction = GET_extra_people_filter_from_params();
$groupRestriction = GET_extra_group_filter_from_params();
$r = [];
foreach (['supannRoleGenerique', 'supannActivite', 'eduPersonAffiliation'] as $table) {
if (in_array($table, $kinds)) {
$filters = ["(up1TableKey=*)"];
if ($table === 'supannRoleGenerique') $filters[] = '(up1Flags={PRIO}*)'; // only "important" ones
if ($table === 'supannActivite') $filters[] = '(|(up1TableKey={UAI:0751717J:ACT}*)(up1TableKey={UAI:0751717J:RIFSEEP}*))'; // only "important" ones
if ($token) $filters[] = ldapOr(["(displayName=*$token*)", "(cn=*$token*)"]);
$filter = array_merge($token ? ["(up1TableKey=$token)"] : [], [ldapAnd($filters)]);
$r[$table] = getLdapInfoMultiFilters("ou=$table,ou=tables,$BASE_DN", $filter, array('up1TableKey' => "key", "displayName" => "name"), "key", $maxRows === 1 ? 1 : 0);
}
}
if (in_array('users', $kinds)) {
$wanted_user_attrs = people_attrs($user_attrs);
$attrRestrictions = attrRestrictions();
global $USER_KEY_FIELD;
$r['users'] = searchPeople(people_filters($token, $restriction), $attrRestrictions, $wanted_user_attrs, $USER_KEY_FIELD, $maxRows);
}
if (in_array('groups', $kinds)) {
$r['groups'] = searchGroups($token, $maxRows, $groupRestriction, $group_attrs);
}
echoJson($r);
?>