LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PhP & Ldap : Undefined attribute type (https://www.linuxquestions.org/questions/linux-newbie-8/php-and-ldap-undefined-attribute-type-870573/)

jonaskellens 03-23-2011 04:05 PM

PhP & Ldap : Undefined attribute type
 
Hello,

I'm trying to add ldap entries from a csv-file, like this :

while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024);
if ($line_of_text[0]!="" || $line_of_text[1]!="") {
$name=$line_of_text[0];
$telephone=$line_of_text[1];

$info["cn"] = $name;
$info["sn"] = $name;
$info["telephonenumber"] = $telephone;
$info["objectclass"] = "inetOrgPerson";

$r2 = ldap_add($ds, "cn=$name,ou=contacts,ou="domain",dc=tld", $info);
echo "Add result is " . $r2 . "<br>";
echo("msg: '".ldap_error($ds)."'<br>");
} # if
} # while
fclose($file_handle);


I'm always getting the output :

Add result is
msg: 'Undefined attribute type'


All goes well when I add just one entry :

Mar 23 21:45:18 vps slapd[25734]: conn=1254 op=1 ADD dn="cn=Coll X,ou=contacts,ou=domain,dc=tld"
Mar 23 21:45:18 vps slapd[25734]: conn=1254 op=1 RESULT tag=105 err=0 text=

But when I want to add multiple entries in a loop-statement, then :

Mar 23 21:53:10 vps slapd[25734]: conn=1258 op=6 ADD dn="cn=Coll X,ou=contacts,ou=domain,dc=tld"
Mar 23 21:53:10 vps slapd[25734]: conn=1258 op=6 RESULT tag=105 err=17 text=dirname: attribute type undefined


Anyone an idea about this "attribute type undefined" ??

paulsm4 03-23-2011 04:46 PM

Suggestions:
1. Please make sure your double- and single-quotes all balance, and you have "$" on all your variables. Especially:
Code:

$r2 = ldap_add($ds, "cn=$name,ou=contacts,ou="domain",dc=tld", $info);
2. Please use code tags (it makes syntax errors *so* much easier to see ;))

jonaskellens 03-24-2011 02:48 AM

Quote:

Originally Posted by paulsm4 (Post 4301039)
Suggestions:
1. Please make sure your double- and single-quotes all balance, and you have "$" on all your variables. Especially:
Code:

$r2 = ldap_add($ds, "cn=$name,ou=contacts,ou="domain",dc=tld", $info);
2. Please use code tags (it makes syntax errors *so* much easier to see ;))

1. I've changed some information to mask the real values. Actually the line reads :

Code:

$r2 = ldap_add($ds, "cn=$name,ou=contacts,ou=".$domain.",dc=tld", $info);
However there is no problem when adding a single value... So I don't think it's a syntax problem...

Why does ldap not accept multiple add-statements ? Should I disconnect and re-connect before every add-operation ?!

I've read somewhere about adding an "end-of-line" because ldap wants every entry on a new line. Is this not the case here ?

jonaskellens 03-24-2011 04:28 AM

It appears to be a very very very stupid question.

Apparently I already had somewhere a variable $info[], so the different attributes of the ldap_add where scrambled.

Thanks for feedback.


All times are GMT -5. The time now is 01:27 PM.