On 4 Dec 2007, at 08:09, Olivier Nicole wrote:
Hello,
I want to implement a print quota system using OpenLDAP. The print
quota would be just one attibute that will keep the number of pages
printed for each user.
My problem is that I have several servers with pinter daemon, and on
each server I may have several printer queues, ending up in many
Perl scripts that can update the LDAP attribute at same time.
The update should be of the form:
printdPages = printedPages + n
How can I do that in Perl (Net::LDAP) avoiding conflicts? I think it
should be implemented as a transaction, but I cannot find proper
reference.
There's nothing in the base LDAP standards for doing this. The best
you could do is to do a read of the original value, then attempt a
replace of the old value with the new value. If that fails, go back to
the beginning and re-read the (new) original value...
Clearly that sucks.
The better way to do this uses an LDAP extension called Modify-
Increment, defined in RFC 4525. It lets you modify a stored "integer-
like" attribute value by a provide (positive or negative, I think)
number in a single modify operation.
Net::LDAP would need a few minor tweaks to be able to support that
RFC, but your biggest problem is finding a server that implements that
extension...
Cheers,
Chris