# LDAP User Manual

## Introduction

**LDAP** (Lightweight Directory Access Protocol) is a standard protocol used to access and manage information stored in directory services, such as *Active Directory* from Microsoft, the *OpenLDAP* among others. It is often used to centralize information about users, groups and resources on a network, such as in authentication systems, contact directories and access management systems.

{% hint style="info" %}
This manual covers the use of LDAP with the tool [Apache Directory Studio](https://directory.apache.org/studio/).
{% endhint %}

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-18546057525c40e90ea4c59b01ca611b500d8222%2FapacheDirectoryStudio_logo.png?alt=media)

## Getting started

### Creating a connection

From the File -> New menu the *Wizard*, choose LDAP Browser -> LDAP Connection. Or, in the connections window, right-click and choose New Connection.

Fill in only the `Connection name` (*Connection name*) and the `Hostname` (or IP) and proceed to the next screen.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-6c480cb48327c9350d1af7406120f0a077aba0ee%2FnewLdapConnection_1.png?alt=media)

Fill in the field `Bind DN or User` and `Bind password` as provided by the team that created the LDAP. After configured you can click Check Authentication to confirm access and login to the LDAP.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-ee0c5823bc530972f13e204b649859035a8cd153%2FnewLdapConnection_2.png?alt=media)

{% hint style="success" %}
**(Optional)** On the next screen, *Browser Option*, check `Fetch operational attributes while browsing` to improve visibility of the groups each user belongs to.
{% endhint %}

### Connecting via the Connections tab

Check which server in the list you want to connect to, double-click the chosen server or select it and click the connection icon (highlighted in red in the image below).

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-618a6e243c8a23c34c9224d8618d37ef7d94a73c%2Fconnecting_1.png?alt=media)

If the connection is successful, the server icon will change to yellow:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-8087c9381082eb977965db744ffef9e69a1f5088%2Fconnecting_2.png?alt=media)

## LDAP structure

### Directory tree

The tree used is essentially based on *Groups* and *Users*, and may additionally include *Policies* for password policies.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-72896cf1efc1e064f9d4084ccc16405e4c122c48%2FdirectoryTree.png?alt=media)

### Acronyms

<table><thead><tr><th width="200">Acronym</th><th>Meaning</th></tr></thead><tbody><tr><td><code>dc</code></td><td>Domain Component</td></tr><tr><td><code>or</code></td><td>Organizational unit to which the user belongs (Organizational Unit)</td></tr><tr><td><code>cn</code></td><td>Common name (Common Name)</td></tr><tr><td><code>sn</code></td><td>Person's name (Surname)</td></tr><tr><td><code>uid</code></td><td>User ID</td></tr><tr><td><code>mail</code></td><td>e-mail (Email Address)</td></tr></tbody></table>

### Tree *Users*

In this tree users are created and their passwords defined; it can be structured in sublevels to facilitate organization of users using the concept of grouping by location, department, etc.

### Tree *Groups*

In this tree groups are defined that will represent permissions/roles of access to the tools, by adding the user to the desired access group.

Example of groups:

* `etr_view` - Users added to this group will have access to the permissions defined in the group, which represent access options to ETR as viewer.
* `bcc_verify` - Users added to this group will be able to log into BCC and perform verification searches (1:1 searches).

### User registration

When creating a user, fill in the following attributes:

`cn` - used as the name of the **login** of the user; `sn` - used to register the **full name** of the user; `uid` - reserved for future use, should be filled with the same text as the `cn`; `password` - filled in with the **password** of this user; `mail` - used to register the **e-mail** of the user.

To register a user, right-click on `ou=User` and choose New -> New Entry:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-db011eff93b0543c57154fd77a9f3b53819b7503%2FnewUser_1.png?alt=media)

The user creation screen will open. If there are `or` intermediate, change the path in the creation directory. Otherwise, if no change is made, the user will be created at the root of the directory *Users*.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-cb87eeedcd5c0b177c637512e48599787397440f%2FnewUser_2.png?alt=media)

On the next screen, remove `organizationalUnit`:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-ba79a25acdc0597bbffd97e0bef2e63d6c80575a%2FnewUser_3.png?alt=media)

Add `inetOrgPerson` and the application will automatically bring the dependency classes `organizationalPerson`, `person` and `top`:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-5394be5cff3fe53258a7e991c8b35780eb8cbbc9%2FnewUser_4.png?alt=media)

Proceed to the next screen to choose the `cn`. Fill in with the `cn` login desired:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-07b52523bbb277fe63dfa059726e6e718207bc84%2FnewUser_5.png?alt=media)

In this new screen a summary of what will be done is displayed and you can change the `sn`. Fill in, if possible, with the user's full name.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-13f3b2fe34a13e596dbd2eea289ec242be6baad9%2FnewUser_6.png?alt=media)

Then, right-click and choose New Attribute:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-0b1d4684bb63f1bb5b9c914873468af2845240f5%2FnewUser_7.png?alt=media)

Choose `UID` and fill in with the value of the `UID`.

{% hint style="info" %}
The value of the `UID` must come from the system user administrator.
{% endhint %}

Next, the attribute `userPassword`:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-8c295718cd1c4cfc25bfa0f278c466f48e995188%2FnewUser_8.png?alt=media)

When finishing, the screen to set the password will open. Choose `CRYPT-SHA-512` and fill in with the desired password:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-77ecc3768330c355016c5c2a668544c925e6eabe%2FnewUser_9.png?alt=media)

Finally, delete the *objectClass* `organizationalPerson (structural)` by right-clicking and choosing Delete Value:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-ad5842ea8c4acd7d6e32592a170138fdeda1c8c1%2FnewUser_10.png?alt=media)

### Adding a group to a user

Under *Users*, open the user record and copy the **DN** of the user shown in the header of the screen:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-f84112d97c7737e65c290c7012bed79bb4bb0853%2FaddGroupToUser_1.png?alt=media)

{% hint style="info" %}
**DN** is the acronym for *Distinguished Name*, which is the **Distinguished Name** of the object in LDAP. It is the way to uniquely identify an object in the directory. It provides the path to the specific entry within the LDAP directory hierarchy, which is organized in a tree structure. A DN is composed of a sequence of relative distinguished names (RDNs) connected by commas. Each RDN is a component of the DN that represents a specific attribute value.

For example:

<img src="https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-eced749a9233136ad975290ac29af7c8993a357a%2FaddGroupToUser_2.png?alt=media" alt="" data-size="original">

* `cn=leandro.pinheiro`: **Common Name** (`cn`) of the entry. It is generally used for names of people or objects.
* `ou=Users`: **Organizational Unit** (`or`) where the entry is located.
* `dc=oldap`: **Domain Component** (`dc`). It can represent a subdomain or a specific part of the domain within the LDAP structure.
* `dc=igp`: Another **Domain Component** (`dc`). Represents another part of the domain, possibly indicating a department or subdivision within the organization.
* `dc=griaule`: **Domain Component** (`dc`) of higher level. Represents the organization's main domain.

Therefore, the DN `cn=leandro.pinheiro,ou=Users,dc=oldap,dc=igp,dc=griaule` identifies a specific user named `leandro.pinheiro` within the organizational unit `Users`, which is part of the subdomain `oldap`, of the domain `igp`, within the main domain `griaule`. This DN provides a clear and unique path to locate this specific entry in the organization's LDAP directory.
{% endhint %}

Then, open the root of *Groups* and choose the desired group. Right-click on the group and choose New Attribute. In `Attribute Type`, choose `member`. Click Finish.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-fae970f51c0aefcb099fffd2981fc58cf27406fb%2FaddGroupToUser_3.png?alt=media)

On the **DN Editor**, paste the **DN** full user (copied in the first step). Click OK:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-d26e5a188ccc23095f0efdbbd234acfef92ad0c4%2FaddGroupToUser_4.png?alt=media)

### Quick addition of a group to a user

When the group already has users/members, adding a new user to the group is faster: just right-click on the component `member` and choose New Value. The **DN Editor** screen will open. Then, as shown in the previous section, paste the **DN** full user and click OK.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-9457ef29204866f838c35220c45632b5251e885d%2FquicklyAddGroupToUser.png?alt=media)

### Removing the user from a group

Open the group in which the user is:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-df03b65828b603b210252f1eecce8449d2f9e4b6%2FdeleteUserFromGroup_1.png?alt=media)

Right-click on the `member` of the user you want to remove from the group and click Delete Value:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-45929fddf26cb318601ad7c80a02faac2ea45fae%2FdeleteUserFromGroup_2.png?alt=media)

Confirm by clicking OK:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-57430f56eb62435d48f7848375c2415b08988bf3%2FdeleteUserFromGroup_3.png?alt=media)

### Group creation

To create a new group, right-click on `ou=Groups` and choose New -> New Entry.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-375f0685542a0201d99603f72ab0aec64efa1626%2FcreateGroup_1.png?alt=media)

The creation screen will open, similar to user creation. Choose the option `organizationalUnit`.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-3f26a226d7c05750ab5808dd34c73f6da1546700%2FcreateGroup_2.png?alt=media)

Choose `or` and fill in a name; in the example below `LDAP`was chosen. Finish creating the group by clicking Finish.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-4bc12d9a9fbdc6beb7d4892db6947efbed5de13f%2FcreateGroup_3.png?alt=media)

## LDAP navigation

### Searching for user groups using "Quick Search"

To locate a user's groups, go to the LDAP search and select the option `cn` or `member`.

{% hint style="info" %}
By selecting `member`, you will need to search using the **DN** full user.
{% endhint %}

At the top right, check if the following icon is selected:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-59ecfc9897ae5c073e551ead42b89df455d72a74%2FsearchTreeIcon.png?alt=media)

If not, select it. This will allow you to search the entire groups tree (options `search one level only` or `search whole subtree`).

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-48321fc4393b34fb7014bd88a0260a9df95aac61%2FsearchUserGroups_1.png?alt=media)

Check the response in the `Quick Search`:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-732591ed1019e67008e32727cb8d6e1f2e6fd5bf%2FsearchUserGroups_2.png?alt=media)

{% hint style="danger" %}
**Never delete a user using the search result** (in the Quick Search item), because the groups this person belongs to were searched. Therefore, **deleting a line from Quick Search means deleting the group** and not the user.
{% endhint %}

### User's group list in the user's description

Another way to check the groups the user belongs to is through *Fetch*.

For this, right-click on the user's name and choose Fetch -> Fetch Operational Attributes:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-528572a1b0f7065da7ad79f3f582b6e96334a0a5%2FfetchUserGroups_1.png?alt=media)

It is also possible to enable *Fetch Operational Attributes* by right-clicking and choosing Properties. Then, click on `Connection` and open the `Browser Options`. Then, in the `Features`, check the option `Fetch operational attributes while browsing`:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-30f330be2b6a292946e8dd05d114bbb495284a8b%2FfetchUserGroups_2.png?alt=media)

Thus, the groups the user belongs to will be displayed during navigation:

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-7e69d332b3eada3a3aa5ddd30b7eb0141b742fb6%2FfetchUserGroups_3.png?alt=media)

### Password change

Locate the user via Quick Search, as shown [in this step by step](#pesquisa-de-grupos-do-usuario-pelo-quick-search).

After locating the user, double-click on userPassword and open the tab `New Password`.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-a3857ad7ea3a35d6d7b638d4eb01836e588cccfe%2FchangePassword.png?alt=media)

Enter the new password and confirm.

After applying the new password, the *Modification Logs* screen will appear confirming your change.

### Password verification

For password verification, first locate the user via Quick Search, as shown [in this step by step](#pesquisa-de-grupos-do-usuario-pelo-quick-search).

After locating the user, double-click on userPassword and open the tab `Current Password`.

In the field, `Verify Password`, enter the user's current password and click Verify.

If the password is correct, the message "*Password verified successfully*" will be displayed.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-9768423f9fc393561c9eb6a9bfc158a0aec5dc7e%2FverifyPassword.png?alt=media)

## User organization

### Users by subgroups

Efficient organization of users in an LDAP directory can be achieved through subtrees. This structure facilitates directory administration, allowing clear segmentation of users based on specific criteria such as company, department or contracts.

#### Concept of User Subtree

To optimize user management, it is recommended to implement a hierarchical subtree with one or two levels at most of depth. This practice ensures a logical separation of users, bringing clarity and efficiency to directory administration.

#### Advantages of the User Subtree

1. **Simplification of Administration**: Reduces the complexity of LDAP administration.
2. **Structured Organization**: Makes it easier to locate and manage LDAP objects.
3. **Performance Improvement**: Minimizes response time in LDAP queries and operations.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-78974a34a0de8ef7ffba1723d6ca35cc757ace29%2FuserSubgroups_1.png?alt=media)

This structure exemplifies:

* **ROOT**: Root level of the LDAP directory.
* **Organization**: Main organizational unit.
* **UF**: Federative Unit, exemplifying with `SP` (São Paulo).
* **CONTRACT**: Subdivision of contracts, such as `Scientific Police`.
* **USER**: Users within the specific contract.
* **Permission**: Permissions associated with the users.

Another example, this directly in LDAP, consists of a tree of subgroups. Where there is a group `policiaCivil` and inside it a subgroup `SC`.

![](https://3757157672-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7Bx0xNdsdGHpCZ20yxbn%2Fuploads%2Fgit-blob-75fffee00e07fd6010023a2f9e8b49e236f54360%2FuserSubgroups_2.png?alt=media)
