"Bing Du" wrote:
> Does Net::LDAP provide any mechanism to lock an entry before modifying
> it? So other script using Net::LDAP or ldapmodify command can not
> modify the same entry.
LDAP v3 doesn't have any locking mechanisms, therefor Net::LDAP doesn't
have any.
From an application's perspective you can come up with your own
locking protocol... for example, you could define some naming
convention for special lock entries, then to lock a record you'd
attempt to create the lock entry; if creating the lock succeeds
you do your thing and then remove the lock entry. If the create
fails you assume that it's because another process already
created a lock entry and wait and retry or return an error to
the user. This works because you can't create an entry that
already exists, so it's a valid locking protocol. Of course it
only works if all applications that use your directory adhere to
the protocol.
I use a slightly different protocol to atomically read and
increment a special counter entry... I have some LDAP entries
which have a single relevant attribute that's an integer which
I want to be able to read and increment (I use these as UIDs
for new user entries). To do this I rename the entry with
modrdn to name containing a unique (partly random) string, and
if the rename succeeds read the counter, increment and write it,
then rename the entry back to it's normal rdn. If the rename
fails it's because the entry didn't exist (because another
process had already renamed it) so I wait a while and try again.
- Jürgen
> perl -MNet::LDAP -e 'print $Net::LDAP::VERSION,"\n"' shows 0.14.
>
> Thanks,
>
> Bing
>
> Bing Du <bi...@ta..., 979-845-9577>
> Texas A&M University, CIS, Operating Systems, Unix
>
|