LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-23-2011, 05:05 PM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 623

Rep: Reputation: 33
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" ??
 
Old 03-23-2011, 05:46 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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 )
 
Old 03-24-2011, 03:48 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 623

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by paulsm4 View Post
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 ?

Last edited by jonaskellens; 03-24-2011 at 03:58 AM.
 
Old 03-24-2011, 05:28 AM   #4
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 623

Original Poster
Rep: Reputation: 33
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I modify 1 of my ldap attribute if I have 2 same attribute under 1 entry? chinho Programming 1 01-31-2011 04:37 AM
ldap_add: Undefined attribute type (17) additional info: ojectclass: attribute type vinaytp Linux - Newbie 2 05-28-2009 05:57 AM
samba4: LDAP memberOf: attribute type undefined touzeaud Linux - Server 10 04-13-2009 08:03 PM
Warning ___ specifies undefined mime type/service type mbvpixies78 Linux - Software 0 12-29-2007 11:25 PM
OpenLDAP error ldapadd: Undefined attribute type (17) gergaholic Linux - Server 2 11-11-2007 04:03 AM


All times are GMT -5. The time now is 12:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration