Re: PHP ldap_add() - null values in fields produce an "value #0 invalid per syntax" error on the ldap server
| From: | David Robley | Date: | Thu, 18 Jul 2002 00:20:32 +0000 |
| Subject: | Re: PHP ldap_add() - null values in fields produce an "value #0 invalid per syntax" error on the ldap server | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20607@lists.php.net to get a copy of this message | ||
In article <200207171917.VAA07866@www.onlineloop.com>,
ian23@midori.shacknet.nu says...
> Hi,
>
> New to the list and hoping someone might be able to help me.
>
> I have been using PHP scripts that are to maintain a company address book
> with a lot of data about contacts, both inside and outside the company. The
> scripts, which are generating html pages and reading input values back in,
> have been working fine with PHP 4.2.1 as a library module for apache 1.3.26
> and openldap 1.2.13. However, openldap 2.0.23 and 25 have been generating
> errors with these same PHP scripts.
>
> The problem comes when fields in the html pages are left empty, which is
> normal for this application. For those familiar with the ldap_add/modify
> functions in PHP, the array that is passed in has some values, say for
> example title, fax, mobile, ... left empty, and therefore NULL (I have
> checked, they really are NULL's stored in the array). When the values make
> it to the ldap server however, they appear to be no longer NULL's, but a
> "#0", and through debugging output on the ldap server, I have seen it is
> generating an "invalid per syntax" error.
>
> The ldap servers have been complied from source and installed on a SuSE linux
> professional 7.3 system. Hardware resources are no problem (640Mb RAM, 2Gb
> swap, 800Mhz processor, 130Gb HDD space with 6Gb free on the working
> partition with this stuff)
>
> Does anyone have any suggestions as to how I can address this problem. It
> is important that null values can make it into the ldap server as putting in
> other values to try to work around the problem will mess up other
> applications that use the ldap server, as will not inserting the fields into
> the ldap server.
>
> Ian
>
> The following code segment demonstrates the problem:
>
> <?php
> $ds=ldap_connect("localhost"); // The LDAP server is on this host
>
> if ($ds) {
> // bind with appropriate dn to give update access
> $r=ldap_bind($ds,"cn=ShnetAdmin, o=shnetdemo", "thepassword");
>
> // prepare data
> $info["cn"]="John Jones";
> $info["sn"]="Jones";
> $info["mail"]=""; // <----- NULL VALUE HERE!!!!!!
> // The following lines also produce the same result.......
> //$info["mail"]=NULL; // <------- NULL value here!!!!!!!
> //$info["mail"]="\0"; // <------- NULL value here!!!!!!!
> //$info["mail"]; // <------- NULL value here!!!!!!!
Perhaps if you were to test that the relevant values were not empty; only
add them to the ldap database if they have a value? empty or isset are the
functions to investigate.
Cheers
--
David Robley
Temporary Kiwi!
Quod subigo farinam