Michael, thanks for your suggestion. I read the RFC and it seemed to say that I 
just need to escape the parenthesis with a backslash. I implemented this in 
this section of my program:
            // 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'];

            // generate password here
            $password=generate_password();
            $info['userpassword']='{MD5}'.base64_encode(md5($password, true));
            $local_dn='cn='.$info['cn'].",".$rdn;
echo '$local_dn is ' . $local_dn . "\n";
            // do the actual insertion
            if (!ldap_add($connection,$local_dn,$info))  #This is line 141
            {
                echo "Failed to add user: ".$info['uid']."\n";
            }else
            {

And get this error message:

[EMAIL PROTECTED]:/var/www/centernet/htdocs/ldap_auth$ php conversion.php

$local_dn is cn=E. Kevin \(Kev\) Zembower,ou=ccpperson,dc=jhuccp,dc=org

Warning: ldap_add(): Add: Invalid DN syntax in 
/var/www/centernet/htdocs/ldap_auth/conversion.php on line 141
Failed to add user: kzembowe
[EMAIL PROTECTED]:/var/www/centernet/htdocs/ldap_auth$

The local echo of $local_dn seems to be fine and what I expected. Can anyone 
give me any more advice on how to transform this into an acceptable DN?

Thanks for your suggestions and advice.

-Kevin

-----Original Message-----
From: Michael Ströder [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 24, 2007 1:34 PM
To: Zembower, Kevin
Cc: [email protected]
Subject: Re: [ldap] Newbie: best method for using special characters?

Zembower, Kevin wrote:
> 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.

Read about special chars for DNs in RFC 4514.

Ciao, Michael.

---
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