[Ovirt-devel] index 13deae2..82595cb 100755

Hugh O. Brock hbrock at redhat.com
Wed May 21 17:45:15 UTC 2008


For general interest on the list, below is the patch Darryl just pushed
to grant_admin_privileges to finally get ldap working with activeLdap
and freeipa.

--Hugh

>  
>  require 'active_record_env'
>  
> -require 'rubygems'
> -
> -gem 'activeldap'
> -require 'active_ldap'
> -
> -require '/usr/share/ovirt-wui/app/models/account'
> -
> +# Get configuration options...
>  ldap_config = YAML::load(File.open("#{OVIRT_DIR}/config/ldap.yml"))
>  uid = ARGV[0]
> -base, host, port = ldap_config["production"]["base"], ldap_config["production"]["host"], ldap_config["production"]["port"]
> -
> -ActiveLdap::Base.establish_connection(:base => base, :host => host, :port => port)
> +base, host = ldap_config["production"]["base"], ldap_config["production"]["host"]
>  
> -#
> -# If the uid is found in LDAP, then create an admin account
> -# for that user. Otherwise, report an error and fail.
> -#
> +ActiveLdap::Base.establish_connection :base => base, :host => host, :try_sasl => false
>  
> -puts "Validating UID #{uid} in LDAP"
> -
> -begin
> -  user = Account.find("uid=#{uid}")
> -rescue StandardError => error
> -  puts "Unable to verify user in LDAP or no such user exists: uid=#{uid}" 
> -else
> +if Account.exists?("uid=#{uid}")
> +  puts "Creating an admin account for #{uid}..."
>    $hwpool = HardwarePool.get_default_pool
> -  if $hwpool
> -    Permission.new( {:user_role => Permission::ROLE_SUPER_ADMIN,
> -		     :uid       => $uid,
> -		     :pool_id   => $hwpool.id}).save
> -  end
> +  permission = Permission.create(:user_role => Permission::ROLE_SUPER_ADMIN,
> +				 :uid       => uid,
> +				 :pool_id   => $hwpool.id)
> +else
> +  puts "Unable to verify user: uid=#{uid}"
>  end
> 
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel




More information about the ovirt-devel mailing list