> For the complete documentation index, see [llms.txt](https://ajuda.rnp.br/cafe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajuda.rnp.br/cafe/idp-cafe/faq/ajustando-atributos-cpf-e-data-de-nascimento-para-icpedu.md).

# Ajustando Atributos CPF e Data de Nascimento para ICPEdu

{% hint style="info" %}
Informe

Antes de iniciar qualquer ação deste roteiro primeiro verificar a versão do seu servidor Ubuntu.

Este roteiro so irá funcionar para aquelas instituições que já possuem a versão da VM IdP a partir da versão 24.04 do sistema operacional Ubuntu, com a versão 5.1.X do Shibboleth caso a sua instituição não esteja dentro deste requisito não realizar este operação e entrar em contato com o ServiceDesk da RNP, pois será necessário realizar a atualização do seu IdP.
{% endhint %}

## Guia passo a passo para AD:

{% hint style="danger" %}
Antes de começar !

Como a microsoft AD não implementa por padrão os atributos "**schaDateOfBirth**" e o "**brPersonCPF**" eles não são mapeados, com isso será necessário o uso de atributos que estejam vagos em seu AD para que os mesmos sejam mapeados para o Shibboleth em seu IdP. Nesse procedimento foi usado os seguintes atributos **employeeNumber** e **employeeType**

Nesse roteiro usamos o atributo **employeeNumber** para valores da Data de Nascimento e o atributo **employeeType** para valores do CPF

{% endhint %}

O shibboleth IDP em sua versão 5.1.x veio com algumas alterações na configuração de atributos, configurações essas que vieram para melhorar a manutenção e customização do IDP pelos responsáveis do serviço. Nessa versão tivemos a inlcusão de um novo recurso dentro do diretório /conf agora dentro desse diretório encontramos o sub diretório /attributes.

Esse sub diretório /attributes agora fica responsável por conter arquivos de configuração .xml que tratam sobre as especificações dos atributos suportados pelo IDP. Dentro desse diretório você verá os arquivos dividídos pelos seus respectivos schemas.

Para essa adequação do CPF e Data de Nascimento foi usado atributos que já estão mapeados pelo IDP dentro do schema .../conf/attributes/inetOrgPerson.xml e também já são atributos presentes no Microsoft AD.&#x20;

Optamos por usar os atributos employeeNumber e employeeType   &#x20;

#### Seguir as etapas abaixo:

Dentro do seu Microsoft AD você precisa abrir o Editor de Atributos dos usuários e procurar pelos atributos employeeNumber e employeeType, veja figura abaixo:

![](https://3706451151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M94Z581aPIo4Bzo9ImS%2Fuploads%2FiLS894eZz9iJ31X2XH1U%2FAtributos-AD.png?alt=media\&token=63c87333-847d-4fc4-991a-8ca849b1cfab)

Faça o preenchimento desses atributos seguindo a orientação de usar valores para Data de Nascimento em employeeNumber, sempre no formato AAAAMMDD e os valores para o CPF em employeeType, sempre no formato inteiro sem pontos e hífen.

#### Validação do Attribute-resolver.xml

Uma vez os valores populados em seu AD podemos agora configurar o shibboleth para que ele leia esse valores e entregue como se fosse o sachDateOfBirth e o brPersonCPF, passo a passo logo abaixo:&#x20;

Abrir e editar o arquivo "**attribute-resolver.xml**", caminho: **/opt/shibboleth-idp/conf** e procure pelas entradas com id=brPersonCPF e id=schacDateOfBirth eles estão perto um do outro.

<pre class="language-xml" data-title="/opt/shibboleth-idp/conf/attribute-resolver.xml" data-line-numbers><code class="lang-xml">    &#x3C;!-- CAFe - brPersonCPF -->
    &#x3C;AttributeDefinition id="brPersonCPF" xsi:type="Simple">
<strong>        &#x3C;InputDataConnector ref="dcLDAP" attributeNames="brPersonCPF" />
</strong>    &#x3C;/AttributeDefinition>

    &#x3C;!-- CAFe - schacDateOfBirth -->
    &#x3C;AttributeDefinition id="schacDateOfBirth" xsi:type="Simple">
<strong>        &#x3C;InputDataConnector ref="dcLDAP" attributeNames="schacDateOfBirth" />
</strong>    &#x3C;/AttributeDefinition>

</code></pre>

Vamos nesse momento alterar os valores de referencia desses dois atributos, temos que alterar a entrada da variável attributeNames="brPersonCPF" e attributeName="schacDateOfBirth" para os seguintes valores:

attributeNames="employeeType"

attributeNames="employeeNumber"&#x20;

<pre class="language-xml" data-title="/opt/shibboleth-idp/conf/attribute-resolver.xml" data-line-numbers><code class="lang-xml">    &#x3C;!-- CAFe - brPersonCPF -->
    &#x3C;AttributeDefinition id="brPersonCPF" xsi:type="Simple">
<strong>        &#x3C;InputDataConnector ref="dcLDAP" attributeNames="employeeType" />
</strong>    &#x3C;/AttributeDefinition>

    &#x3C;!-- CAFe - schacDateOfBirth -->
    &#x3C;AttributeDefinition id="schacDateOfBirth" xsi:type="Simple">
<strong>        &#x3C;InputDataConnector ref="dcLDAP" attributeNames="employeeNumber" />
</strong>    &#x3C;/AttributeDefinition>
    
</code></pre>

Procurar no arquivo de configuração na secção de Data Connectors a entrada **\<dc:ReturnAttributes>...\</dc:ReturnAttributes>**, ela faz referência aos atributos que serão retornados pelo seu IdP, essa configuração ainda deve ser feita no arquivo **attribute-resolver.xml**.

<pre class="language-xml" data-title=" /opt/shibboleth-idp/conf/attribute-resolver.xml" data-line-numbers><code class="lang-xml"><strong>    &#x3C;!-- ========================================== -->
</strong>    &#x3C;!--      Data Connectors                       -->
    &#x3C;!-- ========================================== -->

    &#x3C;DataConnector id="dcLDAP" xsi:type="LDAPDirectory" ldapURL="%{idp.attribute.resolver.LDAP.ldapURL}" baseDN="%{idp.attribute.resolver.LDAP.baseDN}" principal="%{idp.attribute.resolver.LDAP.bindDN}" principalCredential="%{idp.attribute.resolver.LDAP.bindDNCredential}" useStartTLS="%{idp.attribute.resolver.LDAP.useStartTLS:true}" noResultIsError="%{idp.attribute.resolver.LDAP.noResultsIsError:false}" multipleResultsIsError="%{idp.attribute.resolver.LDAP.multipleResultsIsError:true}">
        &#x3C;FilterTemplate>
            &#x3C;![CDATA[
                %{idp.attribute.resolver.LDAP.searchFilter}
            ]]>
        &#x3C;/FilterTemplate>
<strong>        &#x3C;ReturnAttributes>%{idp.authn.LDAP.returnAttributes} sAMAccountName mail cn givenName sn <a data-footnote-ref href="#user-content-fn-1">employeeType employeeNumber</a> objectGUID&#x3C;/ReturnAttributes>
</strong>        &#x3C;BinaryAttributes>objectGUID&#x3C;/BinaryAttributes>
    &#x3C;/DataConnector>
</code></pre>

Nessa parte do bloco você deve acrescentar os dois novos atributos na linha de entrega, veja como deve ficar após sua alteração:

* `<ReturnAttributes>%{idp.authn.LDAP.returnAttributes} mail cn givenName sn brPersonCPF schacDateOfBirth`**`employeeType employeeNumber`** `objectGUID</ReturnAttributes>`&#x20;

{% hint style="info" %}
Muito importante que você inclua os dois atributos referenciados pelo seu AD para serem usados como CPF e Data de Nascimento, dentro desta linha do código, pois é ela quem irá liberar esses atributos e entrega-los ao serviço.
{% endhint %}

Faça a modificação, caso necessário, adicione a regra para a libração dos atributos CPF e Data de Nascimento para o ICPedu, salve o arquivo e feche.

#### Validação do Attribute-filter.xml

brir e editar o arquivo "**attribute-resolver.xml**", caminho: **/opt/shibboleth-idp/conf** e procure pela entrada`<AttributeFilterPolicy id="releaseToRNP">` .

Caso as linhas abaixo estejam comentadas, realizar a liberação:

<pre class="language-xml" data-title="/opt/shibboleth-idp/conf/attribute-filter.xml" data-line-numbers><code class="lang-xml">        &#x3C;/PolicyRequirementRule>

<strong>        &#x3C;!--
</strong><strong>        &#x3C;AttributeRule attributeID="schacDateOfBirth">
</strong><strong>            &#x3C;PermitValueRule xsi:type="ANY" />
</strong><strong>        &#x3C;/AttributeRule>
</strong><strong>        -->
</strong>
<strong>        &#x3C;!--
</strong><strong>        &#x3C;AttributeRule attributeID="brPersonCPF">
</strong><strong>            &#x3C;PermitValueRule xsi:type="ANY" />
</strong><strong>        &#x3C;/AttributeRule>
</strong><strong>        -->
</strong>        
    &#x3C;/AttributeFilterPolicy>

</code></pre>

#### Faça o restart do serviço:

```sh
sudo systemctl restart jetty.service
```

{% hint style="danger" %}
Informe

A inclusão do bloco de código deve estar contida dentro das tags "\<resolver:AttributeResolver" e "\</resolver:AttributeResolver>" que são as declarações de inicio e fim do arquivo attribute-filter.xml.

No exemplo citado estamos liberando os atributos CPF e Data de Nascimento apenas para o SP de teste da RNP e para os SPs dos serviços P1 e Pessoal do ICPEDU. Lembrando que os atributos devem existir no serviço de diretório da institução em forma de atributo do usuário.
{% endhint %}

[^1]: Inserir os atributos


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://ajuda.rnp.br/cafe/idp-cafe/faq/ajustando-atributos-cpf-e-data-de-nascimento-para-icpedu.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
