|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-04-13 09:02 UTC] e dot vandeoudeweetering at marcanti dot esprit-sg dot
Description:
------------
I try to update a multi valued Active Directory attribute. The (COM) function expects an array as the third parameter.
When the function is called, PHP produces an error. (See Reproduce code :)
I tried the same on my second server that's running:
PHP 4.3.4 (cli) (built: Nov 2 2003 23:47:34)
The code is executed without any problems.
Did something changed in the way PHP treats arrays, or did COM changed?
Reproduce code:
---------------
<?php
define("APPEND", 3);
$adsi = "cn=user,ou=test,dc=php,dc=net";
$user = new COM("LDAP://" . $adsi);
$user -> PutEx(APPEND, "otherHomePhone", array("123", "456", "789"));
$user -> SetInfo();
?>
Expected result:
----------------
Active Directory should update the multi-valued attribute 'otherHomePhone' with the values specified in the array.
Actual result:
--------------
Exception thrown
File : C:\php\includes\test.php
Line : 6
Message : Source: Active Directory
Description: Unspecified error
Code : -2147352567
TraceString :
#0 {main}
Array
(
)
Trace : 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Hi Wez, I installed the CVS version [5.0.0RC2-dev, 22 Apr 2004 08:32:53] and did the following tests: ### PHP Code ### <?php define("APPEND", 3); $adsi = "cn=user,ou=test,dc=php,dc=net"; $user = new COM("LDAP://" . $adsi); $arr = //See the test results! $user -> PutEx(APPEND, "otherHomePhone", $arr); $user -> SetInfo(); ?> ### Test 1 ### $arr = array("123", "456", "789"); PHP Warning: Unknown: COM: converting from PHP array to VARIANT array; only arrays with numeric keys are allowed in C:\php\includes\test.php on line 9 Exception thrown File : C:\php\includes\test.php Line : 9 Message : Source: Active Directory Description: Unspecified error Code : -2147352567 TraceString : #0 {main} ### Test 2 ### $arr = array(0 => "123", 1 => "456", 2 => "789"); PHP Warning: Unknown: COM: converting from PHP array to VARIANT array; only arrays with numeric keys are allowed in C:\php\includes\test.php on line 9 Exception thrown File : C:\php\includes\test.php Line : 9 Message : Source: Active Directory Description: Unspecified error Code : -2147352567 TraceString : #0 {main} As you see, both tests failed. I hope these tests will help you. Best regards, Edwin.I installed the CVS version [5.0.0RC2-dev, 23 Apr 2004 06:30] and did the following tests: ### PHP Code ### <?php define("APPEND", 3); $adsi = "cn=user,ou=test,dc=php,dc=net"; $user = new COM("LDAP://" . $adsi); $arr = array("123", "456", "789"); $user -> PutEx(APPEND, "otherHomePhone", $arr); $user -> SetInfo(); $arr2 = $user -> GetEx("otherHomePhone"); ?> ### Test 1 ### $cnt = count($arr2); for($i = 0; $i < $cnt; $i++) { print $arr[$i] . "\n"; } //Only the 1st of 3 elements is printed //count function results 1. wrong! 3 elements in array ### Test 2 ### foreach($arr2 as $val) { print $val . "\n"; } //All 3 elements are printed! ### Test 3 ### print_r($arr2); //Results: variant Object The COM function PutEx on line 9 works fine!!! Active directory is updated with the correct values in array. The COM function GetEx on line 12 has a small problem. There's no array returned in the function, but an variant object.