十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
公司在异地有分公司。那边要加入域。然后权限等等。。。还有就是ruby学习一下。。。
成都创新互联是一家专注于网站建设、成都网站建设与策划设计,芒康网站建设哪家好?成都创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:芒康等地区。芒康做网站价格咨询:13518219792
require 'net/ldap' require 'net/telnet' require 'net/http' require 'openssl' require 'base64' require 'highline/import' #隐藏输入字符 gem install highline ALG = 'DES-EDE3-CBC' KEY = "masdsdff" #你的密钥 只能8位 DES_KEY = "nseewW3E" #任意固定的值 def check_pass(auth) puts "Input Your Username" username = STDIN.gets.chomp password = ask("Input Your Password") { |q| q.echo = "*" } ldap = Net::LDAP.new ldap.host = "fw.163.net" ldap.port = 389 result = ldap.bind_as( :base => "ou=People,dc=163,dc=net", :filter => "(uid=#{username}))", :password => password ) if result auth.include?(username) ? true : false else false end end def check_network() begin Net::Telnet::new("Host" => "ad.163.net", "Port" => 80, "Telnetmode" => false) rescue puts "Can't Connect AD, Please Check Network." sleep 10 exit end end def check_hostname() if ENV["COMPUTERNAME"].downcase.scan("hw").count > 0 puts "Please Change Hostname And Restart PC" sleep 10 exit end end def usage() help=<0 ? true : false end def encode(str) des = OpenSSL::Cipher::Cipher.new(ALG) des.pkcs5_keyivgen(KEY, DES_KEY) des.encrypt cipher = des.update(str) cipher << des.final return Base64.encode64(cipher) #Base64编码,才能保存到数据库 end def decode(str) str = Base64.decode64(str) des = OpenSSL::Cipher::Cipher.new(ALG) des.pkcs5_keyivgen(KEY, DES_KEY) des.decrypt des.update(str) + des.final end #----------------------- check_network() #usage() 本来用参数,现在改输入 secret = decode(Net::HTTP.get(URI('http://fw.163.net/auth.dat')).chomp).split("|") if check_pass(secret) check_hostname() if add_domain(secret) puts "Add users to the local administrators group? (Y|N)" if STDIN.gets.scan(/[yY]/).count > 0 puts "Please enter a user to join the administrators group" `net localgroup administrators 163.net\\#{STDIN.gets.chomp} /add` end puts "Join a domain successfully" else puts "Join a domain fail" end sleep 10 exit else puts "1: username or password err; 2: unauthorized" sleep 10 exit end
然后用 ocra 编译为exe (ocra 直接 gem install ocra, 这个感觉比exerb、rubyscript2exe好)
同时程序需要 netdom.exe netapi32.dll
注,加密的是在网上找的。忘记哪了。