Sha256: 11cb7dc5c9880200d48ed1972277d633c65ef9338216ca410b0c705591d8c9ea
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
# encoding: UTF-8 module Vines module Command class Ldap def run(opts) raise 'vines ldap <domain>' unless opts[:args].size == 1 require opts[:config] domain = opts[:args].first unless storage = Config.instance.vhosts[domain].storage rescue nil raise "#{domain} virtual host not found in conf/config.rb" end unless storage.ldap? raise "LDAP connector not configured for #{domain} virtual host" end $stdout.write('JID: ') jid = $stdin.gets.chomp jid = [jid, domain].join('@') unless jid.include?('@') $stdout.write('Password: ') `stty -echo` password = $stdin.gets.chomp `stty echo` puts begin user = storage.ldap.authenticate(jid, password) rescue Exception => e raise "LDAP connection failed: #{e.message}" end filter = storage.ldap.filter(jid) raise "User not found with filter:\n #{filter}" unless user name = user.name.empty? ? '<name missing>' : user.name puts "Found user #{name} with filter:\n #{filter}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vines-0.4.0 | lib/vines/command/ldap.rb |
vines-0.3.2 | lib/vines/command/ldap.rb |
vines-0.3.1 | lib/vines/command/ldap.rb |
vines-0.3.0 | lib/vines/command/ldap.rb |