Class: FreeipaEasy::User
- Inherits:
-
Object
- Object
- FreeipaEasy::User
- Defined in:
- lib/freeipa_easy/user.rb
Instance Attribute Summary collapse
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #add_user(first_name, last_name, login, mail, password) ⇒ Object
- #authentication_password ⇒ Object
- #delete_user(login) ⇒ Object
- #disable_user(login) ⇒ Object
- #enable_user(login) ⇒ Object
-
#initialize(url, user, password) ⇒ User
constructor
A new instance of User.
- #modify_user(login, payload_options = {}) ⇒ Object
- #show_user(login) ⇒ Object
- #unlock_user(login) ⇒ Object
Constructor Details
#initialize(url, user, password) ⇒ User
Returns a new instance of User.
6 7 8 9 10 |
# File 'lib/freeipa_easy/user.rb', line 6 def initialize(url, user, password) @url = url @user = user @password = password end |
Instance Attribute Details
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
5 6 7 |
# File 'lib/freeipa_easy/user.rb', line 5 def end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/freeipa_easy/user.rb', line 5 def password @password end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/freeipa_easy/user.rb', line 5 def url @url end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/freeipa_easy/user.rb', line 5 def user @user end |
Instance Method Details
#add_user(first_name, last_name, login, mail, password) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/freeipa_easy/user.rb', line 23 def add_user(first_name, last_name, login, mail, password) begin cn = first_name + " " + last_name payload = {"method":"user_add", "params":[[login], {"cn": cn, "mail": mail, "givenname": first_name, "sn": last_name, "userpassword": password}], "id":0} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#authentication_password ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/freeipa_easy/user.rb', line 12 def authentication_password begin login_freeipa = RestClient::Request.execute(method: :post, url: url+'/ipa/session/login_password', :verify_ssl => false, :payload => "user=#{@user}&password=#{@password}", :headers => {:Referer => url+'/ipa'}) = login_freeipa. rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end true end |
#delete_user(login) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/freeipa_easy/user.rb', line 44 def delete_user(login) begin payload = {"id": 0, "method": "user_del", "params": [[[login]],{ }]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#disable_user(login) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/freeipa_easy/user.rb', line 78 def disable_user(login) begin payload = {"id": 0, "method": "user_disable", "params": [[login], {}]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#enable_user(login) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/freeipa_easy/user.rb', line 112 def enable_user(login) begin payload = {"id": 0, "method": "user_enable", "params": [[login], {}]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#modify_user(login, payload_options = {}) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/freeipa_easy/user.rb', line 129 def modify_user(login,={}) begin .merge!({"all": false, "no_members": false,"raw": false,"rights": false}) test = {"all": false, "no_members": false,"raw": false,"rights": false} payload = {"id": 0, "method": "user_mod", "params": [[login], ]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#show_user(login) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/freeipa_easy/user.rb', line 61 def show_user(login) begin payload = {"id": 0, "method": "user_show", "params": [[login], {"all": false, "no_members": false,"raw": false,"rights": false}]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |
#unlock_user(login) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/freeipa_easy/user.rb', line 95 def unlock_user(login) begin payload = {"id": 0, "method": "user_unlock", "params": [[login], {}]} data_json = RestClient::Request.execute(method: :post, url: @url +'/ipa/session/json', :verify_ssl => false, :cookies => , :payload => payload.to_json, :headers => {:content_type => :json, :accept =>:json, :Referer => url + '/ipa'}) data = JSON.parse(data_json) rescue Exception => e puts "#{e.class}" +": " + "#{e.message}" end data["error"] end |