[Date Prev][Date Next]
Re: How can I lock a record using php-ldap?
Jim C said:
> I need to be able to lock an attribute, series of entries or one record
> and then perform several actions and then unlock the attribute. How can
> this be done?
LDAP does not include a locking protocol. It is not transactional, in the
same sense as a transaction-capable relational database.
> Not being able to do this would constitute a bug because it means that
> there will always be problems with race conditions between scripts.
> This is easily proveable.
Not really an bug, per se... more "outside the problem definition."
> ldapmodify is atomic but we cannot retrieve the number and modify it
> simultaneously. While we are doing the increment there is always the
> possibility that another script will beat us to the punch.
The LDAP client protocol definitely requires some out-of-box thinking...
as has been shown on the list before, you need to be creative (and live
within some constraints).
Presuming you've previously fetched the cached uidnumber as 42; client
increments the value and sends the modify operation (something like):
Since an ldapmodify operation is atomic, and only succeeds in total if all
parts of it succeed, the above will succeed for only one updater. The
others (with an old initial uidnumber=42) will fail the delete, and
therefore the entire "transaction."
Yes, the failed clients will have to refresh, reincrement uidnumber, and
try again. Such is life.
In summary, you can get around a lot of the "problems" with some clever
workings. But don't expect a transactional nature, since you generally
won;t find that in LDAP.
Alan Sparks, UNIX/Linux Systems Administrator <email@example.com>