Module ActiveLdap::Populate
In: lib/active_ldap/populate.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired NotImplemented AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText::Translation Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema/syntaxes.rb lib/active_ldap/xml.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper Translation GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_46_0.png

Methods

Public Instance methods

[Source]

    # File lib/active_ldap/populate.rb, line 4
 4:     def ensure_base(base_class=nil)
 5:       base_class ||= Base
 6:       return unless base_class.search(:scope => :base).empty?
 7: 
 8:       base_dn = DN.parse(base_class.base)
 9:       suffixes = []
10: 
11:       base_dn.rdns.reverse_each do |rdn|
12:         name, value = rdn.to_a[0]
13:         prefix = suffixes.join(",")
14:         suffixes.unshift("#{name}=#{value}")
15:         next unless name == "dc"
16:         begin
17:           ensure_dc(value, prefix, base_class)
18:         rescue ActiveLdap::OperationNotPermitted
19:         end
20:       end
21:     end

[Source]

    # File lib/active_ldap/populate.rb, line 36
36:     def ensure_dc(name, prefix, base_class=nil)
37:       base_class ||= Base
38:       name = name.to_s if name.is_a?(DN)
39:       name = name.gsub(/\Adc\s*=\s*/i, '')
40: 
41:       dc_class = Class.new(base_class)
42:       dc_class.ldap_mapping(:dn_attribute => "dc",
43:                             :prefix => "",
44:                             :scope => :base,
45:                             :classes => ["top", "dcObject", "organization"])
46:       dc_class.base = prefix
47:       return if dc_class.exist?(name)
48:       dc = dc_class.new(name)
49:       dc.o = dc.dc
50:       dc.save!
51:     end

[Source]

    # File lib/active_ldap/populate.rb, line 23
23:     def ensure_ou(name, base_class=nil)
24:       base_class ||= Base
25:       name = name.to_s if name.is_a?(DN)
26:       name = name.gsub(/\Aou\s*=\s*/i, '')
27: 
28:       ou_class = Class.new(base_class)
29:       ou_class.ldap_mapping(:dn_attribute => "ou",
30:                             :prefix => "",
31:                             :classes => ["top", "organizationalUnit"])
32:       return if ou_class.exist?(name)
33:       ou_class.new(name).save!
34:     end

[Validate]