People apparently are trying but still nothing in terms of a packaged solution or a clean/ documented / usable interface.
Anyways amongst the approaches taken I decided to try to "telnet" to the JAMES server and create an account from there. This is how we do it manually:
The same thing (as in above) we shall do programmatically:
This is the code where you can login to JAMES and create a user account from Ruby on Rails :
require 'net/telnet'As you can see this all just to enter the command "adduser USERNAME PWD" on a console's command line. This has potential of doing all administration from the web front end.
def createEmailAccount
tn = Net::Telnet.new({"Host"=> "localhost",
"Port"=> 4555,
"Output_log" => "james_telnet_output_log.log", # default: nil (no output)
"Dump_log" => "james_telnet_dump_log.log" # default: nil (no output)
})
#tn.waitfor (/Login id:/i) { |s| puts s }
sleep 1
tn.puts('root'){|s| puts s}
#tn.waitfor (/Password:/i) { |s| puts s }
sleep 1
tn.puts('password'){|s| puts s}
sleep 1
#tn.waitfor( /Welcome root. HELP for a list of commands/i ) { |c| print c }
username = params[:user][:login] # this is obtained from what the user entered
pwd = params[:user][:login] # any user entered
tn.puts("adduser " + username + " " + pwd ) { |c| print c }
sleep 2
tn.puts("quit")
sleep 1
tn.close
end
Oh, the sleep calls are necessary :( that is one of the quirks of using telnet.
No comments:
Post a Comment