#test user subclass used in tests. Works with ADAM. Change the GUID #and recordscope to your server's config # require 'passiveldap' class TestUser < PassiveLDAP::Base # change the recordbase to your recordbase! passive_ldap \ :id_attribute => :uidnumber, :record_base => "cn=Users,dc=eotvos,dc=elte,dc=hu" passive_ldap_attr \ :cn => {:name => :common_name, :default_value => Proc.new {|s| "test_#{s.id}" } }, :sn => {:name => :surname}, :mail => {}, :othermailbox => {:multi_valued => true, :name => :other_mailbox}, :dn => { :default_value => Proc.new { |s| "cn=test_#{s.id},#{s.class.settings[:record_base]}" }, :hidden => true }, :objectclass => { :default_value => %w{top person organizationalPerson user}, :multi_valued => true, :hidden => true } end class ValidatedUser < PassiveLDAP::Base # change the recordbase to your recordbase! passive_ldap \ :id_attribute => :uidnumber, :record_base => "cn=Users,dc=eotvos,dc=elte,dc=hu", :default_array_separator => "\n" passive_ldap_attr \ :cn => {:name => :common_name, :default_value => Proc.new {|s| "test_#{s.id}" } }, :sn => {:name => :surname}, :mail => {}, :description => {}, :othermailbox => {:multi_valued => true, :name => :other_mailbox}, :givenname => { :type => { :from => Proc.new { |s| "Mr. #{s}" }, :to => Proc.new { |s| s[4..-1] } } }, # Adds or cuts the "Mr. " prefix :dn => { :default_value => Proc.new { |s| "cn=test_#{s.id},#{s.class.settings[:record_base]}" }, :hidden => true }, :objectclass => { :default_value => %w{top person organizationalPerson user}, :multi_valued => true, :hidden => true } validates_presence_of :description validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_format_of_each :other_mailbox, :with => /\A(?:(?:[^@;\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,}))\Z/i, :unless => Proc.new { |s| s.other_mailbox.nil? or s.other_mailbox == "" } end