I'm trying to modify a PHP program written by someone else so that it
correctly inserts LDAP records containing special characters in
distinguished names. I'm working with OpenLDAP 2.3.30 on a Debian etch
system. For instance, if my input file contains "Kevin (Kev) Zembower" I
get an error trying to add it because of the opening parenthesis. I've
tried to convert opening and closing parens thusly:
        $entry['FirstName'] = str_replace('(','\\28',
$entry['FirstName']);
        $entry['FirstName'] = str_replace(')','\\29',
$entry['FirstName']);

It seems to work fine in these lines:
        // search ldap
        // change filter to PeopleID
        $filter='cn='.$entry['FirstName']." ".$entry['LastName'];
        $result=ldap_search($connection,$rdn,$filter);

But it chokes when it gets to here:
$rdn='ou=ccpperson,dc=jhuccp,dc=org';
...
            // insert user in ldap
            /*** add PeopleID ***/
            $info=array();
            $info['ccpactive']='T';
            $info['ccpchecked']='T';
            $info['ccpconfirmation']=generate_id();//generate randomly
            $info['ccpdepartmentid']=$entry['DepartmentID'];
            $info['ccpdivisionid']=$entry['DivisionID'];
            $info['ccpstatustype']=$entry['Status_Typ'];
            $info['ccpworkstatus']=$entry['Status'];
            $info['cn']=$entry['FirstName']." ".$entry['LastName'];
            $info['sn']=$entry['LastName'];
            $info['uid']=$entry['Login'];
            $info['objectclass']='ccpperson';
            $info['mail']=$entry['Email'];
...
            $local_dn='cn='.$info['cn'].",".$rdn;

            // do the actual insertion
            if (!ldap_add($connection,$local_dn,$info)) #This is line
141
            {
                echo "Failed to add user: ".$info['uid']."\n";
            }else
            {

The error is:
Warning: ldap_add(): Add: Naming violation in
/var/www/centernet/htdocs/ldap_auth/conversion.php on line 141

I have two questions. Can anyone help me in this specific instance fix
this problem? Also, in general, is this the preferred way to allow
special characters in LDAP strings?

Thank you for your help and advice.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139 

---
You are currently subscribed to [email protected] as: [EMAIL PROTECTED]
To unsubscribe send email to [EMAIL PROTECTED] with the word UNSUBSCRIBE as the 
SUBJECT of the message.

Reply via email to