1--TEST--
2ldap_modify() - Modify operations that should fail
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--EXTENSIONS--
7ldap
8--SKIPIF--
9<?php require_once('skipifbindfailure.inc'); ?>
10--FILE--
11<?php
12require "connect.inc";
13
14$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
15
16// DN not found
17var_dump(ldap_modify($link, "cn=not-found,$base", ["dc" => "my-domain"]));
18
19// Invalid DN
20var_dump(ldap_modify($link, "weirdAttribute=val", ["dc" => "my-domain"]));
21
22$entry = [
23    "objectClass" => [
24        "top",
25        "dcObject",
26        "organization",
27    ],
28    "dc" => "my-domain",
29    "o"	 => "my-domain",
30];
31
32ldap_add($link, "dc=my-domain,$base", $entry);
33
34$entry2 = $entry;
35$entry2["dc"] = "Wrong Domain";
36
37var_dump(ldap_modify($link, "dc=my-domain,$base", $entry2));
38
39$entry2 = $entry;
40$entry2["weirdAttribute"] = "weirdVal";
41
42var_dump(ldap_modify($link, "dc=my-domain,$base", $entry2));
43?>
44--CLEAN--
45<?php
46require "connect.inc";
47
48$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
49
50ldap_delete($link, "dc=my-domain,$base");
51?>
52--EXPECTF--
53Warning: ldap_modify(): Modify: No such object in %s on line %d
54bool(false)
55
56Warning: ldap_modify(): Modify: Invalid DN syntax in %s on line %d
57bool(false)
58
59Warning: ldap_modify(): Modify: Naming violation in %s on line %d
60bool(false)
61
62Warning: ldap_modify(): Modify: Undefined attribute type in %s on line %d
63bool(false)
64