1--TEST-- 2ldap_modify_batch() - Batch modify operations that should fail 3--CREDITS-- 4Patrick Allaert <patrickallaert@php.net> 5Ondřej Hošek <ondra.hosek@gmail.com> 6--SKIPIF-- 7<?php require_once('skipif.inc'); ?> 8<?php require_once('skipifbindfailure.inc'); ?> 9--FILE-- 10<?php 11require "connect.inc"; 12 13$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); 14 15$addGivenName = array( 16 array( 17 "attrib" => "givenName", 18 "modtype" => LDAP_MODIFY_BATCH_ADD, 19 "values" => array("Jack") 20 ) 21); 22 23// Too few parameters 24var_dump(ldap_modify_batch()); 25var_dump(ldap_modify_batch($link)); 26var_dump(ldap_modify_batch($link, "dc=my-domain,dc=com")); 27 28// Too many parameters 29var_dump(ldap_modify_batch($link, "dc=my-domain,dc=com", $addGivenName, "Invalid additional parameter")); 30 31// DN not found 32var_dump(ldap_modify_batch($link, "dc=my-domain,dc=com", $addGivenName)); 33 34// Invalid DN 35var_dump(ldap_modify_batch($link, "weirdAttribute=val", $addGivenName)); 36 37// prepare 38$entry = array( 39 "objectClass" => array( 40 "top", 41 "dcObject", 42 "organization"), 43 "dc" => "my-domain", 44 "o" => "my-domain", 45); 46 47ldap_add($link, "dc=my-domain,dc=com", $entry); 48 49// invalid domain 50$mods = array( 51 array( 52 "attrib" => "dc", 53 "modtype" => LDAP_MODIFY_BATCH_REPLACE, 54 "values" => array("Wrong Domain") 55 ) 56); 57 58var_dump(ldap_modify_batch($link, "dc=my-domain,dc=com", $mods)); 59 60// invalid attribute 61$mods = array( 62 array( 63 "attrib" => "weirdAttribute", 64 "modtype" => LDAP_MODIFY_BATCH_ADD, 65 "values" => array("weirdVal", "anotherWeirdval") 66 ) 67); 68 69var_dump(ldap_modify_batch($link, "dc=my-domain,dc=com", $mods)); 70?> 71===DONE=== 72--CLEAN-- 73<?php 74require "connect.inc"; 75 76$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version); 77 78ldap_delete($link, "dc=my-domain,dc=com"); 79?> 80--EXPECTF-- 81Warning: ldap_modify_batch() expects exactly 3 parameters, 0 given in %s on line %d 82NULL 83 84Warning: ldap_modify_batch() expects exactly 3 parameters, 1 given in %s on line %d 85NULL 86 87Warning: ldap_modify_batch() expects exactly 3 parameters, 2 given in %s on line %d 88NULL 89 90Warning: ldap_modify_batch() expects exactly 3 parameters, 4 given in %s on line %d 91NULL 92 93Warning: ldap_modify_batch(): Batch Modify: No such object in %s on line %d 94bool(false) 95 96Warning: ldap_modify_batch(): Batch Modify: Invalid DN syntax in %s on line %d 97bool(false) 98 99Warning: ldap_modify_batch(): Batch Modify: Naming violation in %s on line %d 100bool(false) 101 102Warning: ldap_modify_batch(): Batch Modify: Undefined attribute type in %s on line %d 103bool(false) 104===DONE=== 105