Class: LdapShellUtils::LdapConnection
- Inherits:
-
Object
- Object
- LdapShellUtils::LdapConnection
- Defined in:
- lib/ldap-shell-utils/ldap_connection.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ LdapConnection
constructor
A new instance of LdapConnection.
- #search(options) ⇒ Object
Constructor Details
#initialize(config) ⇒ LdapConnection
Returns a new instance of LdapConnection.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ldap-shell-utils/ldap_connection.rb', line 10 def initialize(config) uri = URI.parse( config[:url] ) auth_config = { :method =>:simple, :username =>config[:username], :password =>config[:password] } configuration = { :host=>uri.host, :port=>uri.port, :base=>config[:base], :auth=>auth_config } configuration[:encryption] = { :method => :simple_tls } if(uri.scheme == 'ldaps') @connection = Net::LDAP.new(configuration) self rescue StandardError=>e raise ArgumentError.new(e.) end |
Instance Method Details
#search(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ldap-shell-utils/ldap_connection.rb', line 34 def search() ldap_filter = "" begin ldap_filter = Net::LDAP::Filter.from_rfc2254([:filter]) rescue StandardError=>e raise ArgumentError.new(e.) end [:attributes] += [:creatorsname, :createtimestamp, :modifiersname, :modifytimestamp] if [:audit] @connection.search( :filter=>ldap_filter, :attributes=>[:attributes], :return_result=>true ) end |