lib/adauth/connection.rb in adauth-2.0.1 vs lib/adauth/connection.rb in adauth-2.0.2
- old
+ new
@@ -1,11 +1,14 @@
module Adauth
# Active Directory Connection wrapper
#
# Handles errors and configures the connection.
class Connection
+ include Expects
+
def initialize(config)
+ expects config, Hash
@config = config
end
# Attempts to bind to Active Directory
#
@@ -17,10 +20,12 @@
:port => @config[:port],
:base => @config[:base]
if @config[:encryption]
conn.encryption @config[:encryption]
end
-
+
+ raise "Anonymous Bind is disabled" if @config[:password] == "" && !(@config[:anonymous_bind])
+
conn.auth "#{@config[:username]}@#{@config[:domain]}", @config[:password]
begin
Timeout::timeout(10){
if conn.bind
\ No newline at end of file