summaryrefslogtreecommitdiff
path: root/doc/es_ES/plugin-ldap-client.markdown
blob: 1a34a880db4a5ac25243a148f9d55f029b0cafa8 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Libreria LDAP
============

Para facilirar la integracion LDAP. kanboard tiene su propia libreria LDAP
Esta libreria puede ejecutar operaciones comunes.

Cliente
-------

Clase: `Kanboard\Core\Ldap\Client`

Para conectar a tu servidor LDAP facilmente, usa este metodo:

```php
use Kanboard\Core\Ldap\Client as LdapClient;
use Kanboard\Core\Ldap\ClientException as LdapException;

try {
    $client = LdapClient::connect();

    // Get native LDAP resource
    $resource = $client->getConnection();

    // ...

} catch (LdapException $e) {
    // ...
}
```

Consultas LDAP
--------------

Classes:

- `Kanboard\Core\Ldap\Query`
- `Kanboard\Core\Ldap\Entries`
- `Kanboard\Core\Ldap\Entry`

Ejemplo para una consulta al directorio LDAP:

```php

$query = new Query($client)
$query->execute('ou=People,dc=kanboard,dc=local', 'uid=my_user', array('cn', 'mail'));

if ($query->hasResult()) {
    $entries = $query->getEntries(); // Return an instance of Entries
}
```

Leer una entrada:

```php
$firstEntry = $query->getEntries()->getFirstEntry();
$email = $firstEntry->getFirstValue('mail');
$name = $firstEntry->getFirstValue('cn', 'Default Name');
```

Leer multiples entradas:

```php
foreach ($query->getEntries()->getAll() as $entry) {
    $emails = $entry->getAll('mail'); // Fetch all emails
    $dn = $entry->getDn(); // Get LDAP DN of this user

    // Check if a value is present for an attribute
    if ($entry->hasValue('mail', 'user2@localhost')) {
        // ...
    }
}
```

Usuario Helper
--------------

Clase: `Kanboard\Core\Ldap\User`

Obtener usuario en una sola linea

```php
// Return an instance of LdapUserProvider
$user = User::getUser($client, 'my_username');
```

Grupo Helper
------------

Clase: `Kanboard\Core\Ldap\Group`

Obtener grupos en una linea:

```php
// Define LDAP filter
$filter = '(&(objectClass=group)(sAMAccountName=My group*))';

// Return a list of LdapGroupProvider
$groups = Group::getGroups($client, $filter);
```