google-code-export / ruby-activeldap

Automatically exported from code.google.com/p/ruby-activeldap
Other
1 stars 1 forks source link

new_entry? on existing instantiated LDAP object always returns true #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create instance of existing entry in LDAP
class User < ActiveLdap::Base
  ldap_mapping :dn_attribute => "cn",
               :classes => ["inetOrgPerson"],
               :prefix => "ou=People"
end

2. create new entry (after connecting to LDAP of course)
  user = User.new("me")
  user.new_entry? # return true
  user.save
3. instantiate existing entry
  user = User.new("me")
  user.new_entry?("me") #returns true

At first new_entry? should return false, but more important is other issue.
For me it seems that instantiating new objects which already is in LDAP
must throw some exception - You can modify existing record in LDAP when
thinking that it is newly created one. For existing objects You should use
find method. 
I give You one example from my Rails app:

You try to create existing entry with cn=John. When you enter create
controller's method you want to use new method on that object (which should
create new unique object) but instead you are updating currently existing
one without that knowledge.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by czy...@gmail.com on 30 Oct 2009 at 10:17

GoogleCodeExporter commented 9 years ago
There is a built-in validation for it.
You will get false on "user.save" and user.errors will include "DN is 
duplicated:
..." message.

Original comment by kou...@gmail.com on 1 Nov 2009 at 7:15

GoogleCodeExporter commented 9 years ago
In fact I get true on user.save
Other thing is that user.new_entry should show true only if it does not exist 
in ldap.

Original comment by czy...@gmail.com on 3 Nov 2009 at 8:30