[Ovirt-devel] [PATCH] Finished the LDAP connector.

Darryl L. Pierce dpierce at redhat.com
Thu May 8 15:05:37 UTC 2008


From: Darryl L. Pierce <mcpierce at mcpierce-laptop.localdomain>

---
 wui/src/app/helpers/ldap_connection.rb |   17 +++++++++++------
 wui/src/config/ldap.yml                |    2 +-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/wui/src/app/helpers/ldap_connection.rb b/wui/src/app/helpers/ldap_connection.rb
index 623c02a..af8b41b 100644
--- a/wui/src/app/helpers/ldap_connection.rb
+++ b/wui/src/app/helpers/ldap_connection.rb
@@ -21,23 +21,28 @@
 # connections with an LDAP server.
 #
 class LDAPConnection
-  @@config = YAML.load(File.open("#{RAILS_ROOT}/config/ldap.yml"))
-  
-  # Connects the LDAP server. 
-  def LDAPConnection.connect(base,host,port)
+
+  @@config = YAML::load(File.open("#{RAILS_ROOT}/config/ldap.yml"))
+
+  # Connects the specified LDAP server.
+  def self.connect(base = nil, host = nil, port = nil)
     
+    base = @@config[ENV['RAILS_ENV']]["base"] if base == nil
+    host = @@config[ENV['RAILS_ENV']]["host"] if host == nil
+    port = @@config[ENV['RAILS_ENV']]["port"] if port == nil
+
     ActiveLdap::Base.establish_connection(:host => host,
 					  :port => port,
 					  :base => base) if LDAPConnection.connected? == false
   end
 
   # Returns whether a connection already exists to the LDAP server.
-  def LDAPConnection.connected?
+  def self.connected?
     return ActiveLdap::Base.connected?
   end
 
   # Disconnects from the LDAP server.
-  def LDAPConnection.disconnect
+  def self.disconnect
     ActiveLdap::Base.remove_connection if LDAPConnection.connected?
   end
 
diff --git a/wui/src/config/ldap.yml b/wui/src/config/ldap.yml
index c8b167e..5f8383f 100644
--- a/wui/src/config/ldap.yml
+++ b/wui/src/config/ldap.yml
@@ -1,4 +1,4 @@
 development:
-  hostname: ldap.rdu.redhat.com
+  host: ldap.rdu.redhat.com
   port: 389
   base: dc=redhat,dc=com
-- 
1.5.4.1




More information about the ovirt-devel mailing list