Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ActiveLdap::Base
- ldap_mapping :dn_attribute=>"uniqueIdentifier",:prefix=>"dc=stockport,dc=bsfbh,dc=com",
- :classes=>["bsfbhAccount"]
- end
- ActiveLdap::Base.establish_connection(:host=>"192.168.111.27",:port=>389,:bind_dn=>"cn=root,dc=office",:password=>"secret")
- me = User.new('fox')
- me.cn = "Testing MOD"
- me.save
- gives:
- /usr//lib/ruby/gems/1.8/gems/ruby-activeldap-0.8.0/lib/active_ldap/base.rb:819:in `method_missing': undefined method `cn=' for #<User:0xb7802aac> (NoMethodError)
- from test2.rb:14
- my ldap schema does have the cn attribute.
- the example code looks like this:
- class User < ActiveLdap::Base
- ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People',
- :classes => ['person', 'posixAccount']
- end
- # name, cn and uid are passed via argv
- user = User.new(name)
- user.add_class('shadowAccount')
- user.cn = cn
- user.uid_number = uid
- user.gid_number = uid
- user.home_directory = "/home/#{name}"
- user.sn = "somesn"
- unless user.save
- puts "failed"
- puts user.errors.full_messages
- exit 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement