Hello.
I’m trying to know how to use cgi with ruby.
I have write this file to connect to a ldap server and to insert data:
proxy1LDAP.rb
require ‘ldap’
class Proxy1LDAP
def initialize
@base = “ou=People,dc=mydomain,dc=it”
@admin = “cn=admin,dc=mydomain,dc=it”
@passwd = “xxx”
@conn = LDAP::Conn.new(“localhost”)
@conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
@dominio = “@mydomain.it”
end
def connetti
@conn.bind(@admin, @passwd)
end
def inserisci(account)
newentry = {
“objectClass” =>
[“top”,“person”,“organizationalPerson”,“inetOrgPerson”,“posixAccount”],
“sn” => [account[“cognome”]],
“cn” => [“#{account[“nome”]} #{account[“cognome”]}”],
“mail” => [“#{account[“uid”]}#@dominio”],
“homeDirectory” => [“/var/vmail/#{account[“uid”]}”],
“uid” => [account[“uid”]],
“userPassword” => [“{CRYPT}#{account[‘passwd’]}”],
“employeeNumber” => [account[“codice”]]
}
@conn.add(“uid=#{account[‘uid’]},#@base”, newentry)
end
def cerca
end
def elimina
end
end
and then I have this cgi:
#!/usr/bin/ruby
require ‘proxy1LDAP’
require ‘cgi’
cgi = CGI.new
account = cgi.params
puts “Content-type: text/plain”
puts
#cgi.out(“text/plain”) {
acc=Proxy1LDAP.new
acc.connetti
acc.inserisci(account)
When I run this cgi the web server error is:
/usr/lib/cgi-bin/ruby/accMail1.rb:4:in `initialize’: wrong argument type
Array (expected String) (TypeError), referer:
http://localhost/prove/mail1LDAP.html
What’s the argumenti type error in the initialize method?
If I run proxyLDAP.rb standalone I have no errors and all works well
with ldap server.
Why it doesn’t work if I use the cgi?