[Date Prev][Date Next]
Re: How can I lock a record using php-ldap?
No, there's no such operation (at least that I've ever seen, cover myself).
Not sure you was the subtlety of the proposed operation. The clients do
have to fetch the value in a separate query, true. But each makes an
update that depends on deleting the original value (uidnumber=42). One
client will succeed, and atomically (i.e., in the same ldapmodify
operation) change uidnumber=43. Other clients following, those with the
original uidnumber=42, will fail the whole thing because they cannot
delete the attribute/value uidnumber=42.
Yes, the failing clients need to requery the uidnumber, choose another,
and resubmit the modify. As I said, such is life.
While there's no locking protocol officially, one might simulate something
similar by defining an attribute and an auxiliary class to mix into the
objects where "locking" is needed. This objectclass could have the
attribute as a SINGLE-VALUE type attribute. Clients could then add an
instance of this attribute as a simulation of a locking call -- if it
succeeds, ok; if it fails (because the attribute already exists), the
"lock" fails. Be careful to delete the lock attribute when update is
My thoughts, anyway...
Jim C said:
> Yes but don't we have to retrieve 42 first before we can make changes to
> it? The race condition occurs in the script because we have more than
> one step involved in the retrieve and modify cycle in the script. Is
> there an atomic function of which I am unaware that will allow one to
> retrieve an attribute and alter it's value in the database
> simultaneously? If not then we are stuck.
>> changetype: modify
>> delete: uidnumber=42
>> add: uidnumber=43
Alan Sparks, UNIX/Linux Systems Administrator <firstname.lastname@example.org>