[Ovirt-devel] [PATCH] Modified LDAPConnection to work with an SRV record, then fallback to the ldap.yml file if necessary.

Chris Lalancette clalance at redhat.com
Fri May 23 06:34:37 UTC 2008


Hugh O. Brock wrote:
>>    # Connects the specified LDAP server.
>>    def self.connect(base = nil, host = nil, port = nil)
>> +
>> +    # Use the SRV record for the LDAP server, otherwise
>> +    # default to what is defined in the ldap.yml file.
>> +    unless defined? host
>> +      unless defined? @host
>> +	Resolv::DNS.new
>> +	
>> +	dns.getresources("_ldap._tcp.#{`dnsdomainname`}",Resolv::DNS::Resource::IN::SRV).collect do |resource|
>> +	  @host = resource.address
>> +	end
>> +      end
>> +
>> +      @host = @@config["host"] unless defined? @host
>> +    end
> 
> OK, but there must be a way to get the local domain from a Ruby
> syscall I would think... (i.e. instead of `dnsdomainname`)

Yeah, agreed.  I think there are some methods in the socket class that might do
this for you.  If not, I'm sure there is some native Ruby way to do this, which
is better than shelling out.

Chris Lalancette




More information about the ovirt-devel mailing list