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!!!!!!!
    $info["objectclass"]="person";

    // add data to directory
    $r=ldap_add($ds, "cn=ShnetAdmin, o=shnetdemo", $info);

    ldap_close($ds);
} else {
    echo "Unable to connect to LDAP server";
}
?>


Which produces the following segment of debugging output on the ldap server,
started with "slapd -d 255".


dn2entry_r: dn: "CN=SHNETADMIN,O=SHNETDEMO"
=> dn2id( "CN=SHNETADMIN,O=SHNETDEMO" )
====> cache_find_entry_dn2id("CN=SHNETADMIN,O=SHNETDEMO"): 3 (1 tries)
<= dn2id 3 (in cache)
=> id2entry_r( 3 )
====> cache_find_entry_id( 3 ) "cn=ShnetAdmin,o=shnetdemo" (found) (1 tries)
<= id2entry_r( 3 ) 0x80e72a8 (cache)
====> cache_return_entry_r( 3 ): returned (0)
send_ldap_result: conn=12 op=1 p=2
send_ldap_result: 21::mail: value #0 invalid per syntax
send_ldap_response: msgid=2 tag=105 err=21
ber_flush: 47 bytes to sd 9
  0000:  30 2d 02 01 02 69 28 0a  01 15 04 00 04 21 6d 61   0-...i(......!ma
  0010:  69 6c 3a 20 76 61 6c 75  65 20 23 30 20 69 6e 76   il: value #0 inv
  0020:  61 6c 69 64 20 70 65 72  20 73 79 6e 74 61 78      alid per syntax
ldap_write: want=47, written=47
  0000:  30 2d 02 01 02 69 28 0a  01 15 04 00 04 21 6d 61   0-...i(......!ma
  0010:  69 6c 3a 20 76 61 6c 75  65 20 23 30 20 69 6e 76   il: value #0 inv
  0020:  61 6c 69 64 20 70 65 72  20 73 79 6e 74 61 78      alid per syntax
daemon: select: listen=6 active_threads=1 tvp=NULL
daemon: activity on 1 descriptors
daemon: activity on: 9r
daemon: read activity on 9
connection_get(9)
connection_get(9): got connid=12
connection_read(9): checking for input on id=12
ber_get_next
ldap_read: want=1, got=1
  0000:  30                                                 0
ldap_read: want=1, got=1
  0000:  05                                                 .
ldap_read: want=5, got=5
  0000:  02 01 03 42 00                                     ...B.
ber_get_next: tag 0x30 len 5 contents:
ber_dump: buf=0x080e5fe0 ptr=0x080e5fe0 end=0x080e5fe5 len=5
  0000:  02 01 03 42 00                                     ...B.
ber_get_next
ldap_read: want=1, got=0

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to