[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: php-LDAP: ldap_mod_del doesn't work
This probably isn't the list to post this to but here is your answer anyway.
The PHP ldap_mod_del function requires that you pass not only the attribute name, but also the current value of the attribute.
So assuminge that:
$attrib contains the name of the attribute you want to delete.
$info[0][$attrib][0] contains the attribute and the value that you are deleting
$ds contains your connection id (you had your bind id below, but you don't want that you want the connection id)
$dn contains your records dn
you would do this command
$result = ldap_mod_del ($ds, $dn, $info[0][$attrib][0]);
This would delete on the server $ds in the record $dn the attribute $attrib that has a value of $info[0][$attrib][0]. You can only delete one attribute at a time (even if that attribute is present more than one time in the record, that is why you need to pass the value with it so ldap knows which instance of that attribute to delete).
I hope this helped
Dan
On Thu, 19 Jul 2001 17:17:59 +0200
"Timo" <timo@gerichhausen.de> wrote:
> Hi!
> I'm not sure if this problem is on the php or the ldap side, but I hope
> to get help here either way.
> I'm trying to delete an attribute using the ldap_mod_del function of
> php.
>
>
> $ds=@ldap_connect("localhost");
> if ($ds) {
> $r=@ldap_bind($ds,"cn=".$User.",ou=Personen,o=gat",$Password);
> if ($r) {
> $sr=ldap_list($ds,"ou=personen,o=gat", "cn=".$User, $attrs);
> $info = ldap_get_entries($ds, $sr);
>
> // $User is the Person who is logged in
> // $attr is the attribute I want to delete
>
> $newinfo=array();
>
> $newinfo[$attr]= ""; // $newinfo[$attr]= $info[0][$attr];
>
> ´ //next line fails if newinfo is "" or has the current value
> $c=ldap_mod_del($r, "cn=".$User.",ou=Personen,o=gat", $newinfo);
>
> [snip]
>
> I'm using OpenLDAP 2.0.11 with PHP 4.0.6.
> What does the LDAP-server want to have for deleting the attribute?
> Or is the PHP-Syntax I'm using false?
> (In this case, can somebody help me, please?)
>
> The error message php generates is
> "Warning: LDAP: modify operation could not be completed. in .../xyz.php
> on line xy"
> <- this is the ldap_mod_del-line
>
> The message logged by slapd is
> "RESULT tag=103 err=21 text=$attr: value #0 contains invalid data"
> <- (I replaced the name of the real attribute with $attr)
>
> Thanks for your help
> Timo
--
Daniell Freed
Computer Services
Dewitt, Ross, & Stevens S.C.
He who fights with monsters might take care
lest he thereby become a monster.
And if you gaze for long into an abyss,
the abyss gazes also into you.
Beyond Good and Evil
Friedrich Wilhelm Nietzche