Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
* This is a short example on how to modify a specific entry in the
4
* directory using Net_LDAP2.
5
* The way described here is the more compact one but may be useful too.
6
* The diference is, that this way we use the $ldap object to modify
7
* the entry directly on the server.
8
*/
9
 
10
// We use the fetch_entry.php example to get the LDAP-Entry
11
// which we will modify now.
12
include_once 'fetch_entry.php';
13
 
14
// Okay, we should have a valid Net_LDAP2_Entry object that represents
15
// a real existing entry in our directory.
16
 
17
// What we do now is to specify some actions that should be performed.
18
// Note, that the same rules as in the long version discussed in modify_entry.php
19
// aplly here too, so for replacing attributes, we must specify the absolute new state.
20
$changes = array(
21
    'add' => array(
22
        'mail' => array('foo@example.org', 'test2@example.org'),
23
        'telephoneNumber' => '1234567890'
24
    ),
25
    'replace' => array(
26
        'mail' => array('test1@example.org', 'test2@example.org')
27
    ),
28
 
29
    'delete' => array(
30
        'mail' => 'test2@example.org',
31
        'telephoneNumber' => null     // the null value is important here, since array
32
    )                                 // mode (indexed, associative) is needed to be homogenous
33
);
34
 
35
// Now it is time to transfer the changes to the ldap
36
// directory. However, for security reasons, these lines
37
// are commented out.
38
// You have two options to carry out the changes, with a small but often
39
// very important difference:
40
// The first call will carry out the actions in the order "add->delete->replace",
41
// while the latter will perform the changes in the order you define.
42
// (add->replace->delete, in our example)
43
 
44
 
45
/*
46
// METHOD 1: ORDER = add->delete->replace
47
$result = $ldap->modify($entry, $changes);
48
if (Net_LDAP2::isError($result)) {
49
    die('Unable to update entry: '.$result->getMessage());
50
}
51
*/
52
 
53
/*
54
// METHOD 2: ORDER = add->replace->delete
55
$result = $ldap->modify($entry, array('changes' => $changes));
56
if (Net_LDAP2::isError($result)) {
57
    die('Unable to update entry: '.$result->getMessage());
58
}
59
*/
60
?>