Hi Dmitry, On Thursday, 14. May 2009, Dmitry Katsubo wrote: > So, if one want the entry to be OK both for adding and for replacing do > the following: What do you mean exactly by "one entry both for adding and replacing" ? Do you want to add/replace attributes in an existing entry ?
Or do you want to create an Entry object, push it to the server and hope it is correctly set up so that it can be added, when it does not exist there yet, or modified if it already exists there? If you know the DN already, why don't you do a search(base => $DN, scope=>'base', filter=>'(objectclass=*)') before and try to get the entry from the server. If there is one, you get a nice Net::LDAP::Entry object with the changetype set to 'modify'; if there is none, you know, you need to create one yourself (where the changetype is automatically set to 'add' ;-). > my $entry = Net::LDAP::Entry->new('DN'); # 'add' is default changetype > $entry->add('givenName' => $1); # only for addingg > $entry->changetype('modify'); > $entry->replace('mail' => $2); # for adding and updating > $entry->add(...); > $entry->update($ldap); Personally I do not consider this approach a safe one. Regards Peter -- Peter Marschall pe...@adpm.de