<?php

// -*-PHP-*-
require_once './supannPerson.inc.php';
$token = GET_ldapFilterSafe_or("token", '');
$attrs = GET_or_NULL("attrs");
$maxRows = @$isTrustedIp ? GET_or("maxRows", 0) : min(max(GET_or_NULL("maxRows"), 1), 10);
$showErrors = GET_or_NULL("showErrors");
$showExtendedInfo = GET_or_NULL("showExtendedInfo");
$allowInvalidAccounts = GET_or_NULL("allowInvalidAccounts");
$restriction = GET_extra_people_filter_from_params();
$KEY_FIELD = 'uid';
$ALLOWED_MONO_ATTRS = array('uid', 'mail', 'displayName', 'cn', 'eduPersonPrimaryAffiliation', 'postalAddress', 'eduPersonPrincipalName', 'sn', 'givenName', 'supannEntiteAffectationPrincipale', 'accountStatus', 'shadowFlag', 'shadowExpire', 'shadowLastChange', 'supannCivilite', 'supannListeRouge', 'supannEmpCorps', 'supannAliasLogin', 'uidNumber', 'gidNumber', 'supannEmpId', 'supannEtuId', 'supannCodeINE', 'employeeNumber', 'homeDirectory', 'gecos', 'sambaAcctFlags', 'sambaSID', 'sambaHomePath', 'createTimestamp', 'modifyTimestamp', 'up1BirthName', 'up1BirthDay', 'homePhone', 'homePostalAddress', 'pager', 'supannMailPerso');
$ALLOWED_MULTI_ATTRS = array('supannEntiteAffectation', 'supannEntiteAffectation-ou', 'supannEntiteAffectation-all', 'employeeType', 'eduPersonAffiliation', 'departmentNumber', 'buildingName', 'description', 'info', 'supannEtablissement', 'supannActivite', 'supannActivite-all', 'supannParrainDN', 'supannParrainDN-ou', 'supannParrainDN-all', 'supannRoleEntite', 'supannRoleEntite-all', 'supannEtuInscription', 'supannEtuInscription-all', 'memberOf', 'memberOf-all', 'supannRoleGenerique', 'up1KrbPrincipal', 'roomNumber', 'up1FloorNumber', 'telephoneNumber', 'facsimileTelephoneNumber', 'supannAutreTelephone', 'mobile', 'objectClass', 'labeledURI', 'mailForwardingAddress', 'mailDeliveryOption', 'mailAlternateAddress', 'up1Profile');
global $UP1_ROLES_DN;
if (@$UP1_ROLES_DN) {
    $ALLOWED_MULTI_ATTRS[] = 'up1Roles';
}
// computed
if (!$attrs) {
    $attrs = implode(',', array_merge($ALLOWED_MONO_ATTRS, $ALLOWED_MULTI_ATTRS));
}
$wanted_attrs = array();
foreach (explode(',', $attrs) as $attr) {
    if (in_array($attr, $ALLOWED_MONO_ATTRS)) {
        $wanted_attrs[$attr] = $attr;
    } else {
        if (in_array($attr, $ALLOWED_MULTI_ATTRS)) {
            $wanted_attrs[$attr] = 'MULTI';
        } else {
            error("unknown attribute {$attr}. allowed attributes: " . join(",", array_merge($ALLOWED_MONO_ATTRS, $ALLOWED_MULTI_ATTRS)));
function GET_ldapFilterSafe_or_NULL($name)
{
    return GET_ldapFilterSafe_or($name, NULL);
}