Do you want to delete it from the LDAP server or from the current entry.
To delete it from the server use
$ldap->modify ($dn, delete => {$attribute => $attval});
To delete it just from an entry then your method seems to be quite
reasonable.
On Tue, 7 May 2002, Joseph Kezar wrote:
> I have a strange request. An abbreviated entry looks like this
>
> ________________________
> cn: Joe Smith
> mail: js...@do...
> memberOfGroup: cn=All Staff,ou=Groups,o=Vermont Department of Corrections,c=US
> memberOfGroup: cn=MIS,ou=Groups,o=Vermont Department of Corrections,c=US
> memberOfGroup: cn=Security,ou=Groups,o=Vermont Department of Corrections,c=US
> memberOfGroup: cn=Root,ou=Groups,o=Vermont Department of Corrections,c=US
> _________________________
>
> What I want to do is remove a single memberOfGroup attribute(eg cn=Root). I don't think what I am looking for is $entry->delete('memberOfGroup') as this will erase all of my attributes called memberOfGroup.
>
> Is there a method I am missing to aid me in removing a very precise attribute. Or do I need to script it by hand liek this?:
>
> @memberships = $entry->get_value('memberOfGroup');
> $entry->delete('memberOfGroup');
> foreach (@memberships) {
> $entry->add(memberOfGroup=>"$_") if ($_ ne "cn=Root,ou=Groups,o=Vermont Department of Corrections,c=US");
> }
>
> Is this the most efficient way?
>
|