我正在尝试修复代码中的错误。我已经修复了一些部分。现在我收到了这个错误......
TypeError in Ldap#getAccount
Showing /home/stadler/tool/app/views/layouts/_stylesheets.html.erb where line #5 raised:
wrong argument type #<Class:0xb996604> (expected Data)
Extracted source (around line #5):
2: <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
3: <![endif]-->
4: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
5: <!--<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>-->
6: <!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
7: <%= stylesheet_link_tag 'custom', :media => 'screen' %>
Trace of template inclusion: app/views/layouts/application.html.erb
Rails.root: /home/stadler/tool
Application Trace | Framework Trace | Full Trace
app/views/layouts/_stylesheets.html.erb:5:in `_app_views_layouts__stylesheets_html_erb__369773416_97305840'
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___101889169_97634680'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"kaADQKjwVLpyTx36sZjq+ZYgdrrlWIWLFdlbCDHgDIQ=",
"id"=>"666667",
"commit"=>"Gibs mir ja!"}
当我在我的一个控制器中实现此方法时,错误开始了。
def getGridNumber(group)
base = "ou=Groups, dc=-, dc=-, dc=-"
filter = 'cn='+group
puts filter
attrs = ['gidNumber']
puts group
conn = LDAP::Conn.new($HOST, $PORT)
conn.bind('cn=admin, dc=-, dc=-, dc=-','-')
conn.perror("bind")
begin
conn.search(base, $scope, filter, attrs) { |entry|
@gridNumber=entry.vals('gidNumber').first
puts entry.vals('gidNumber')
}
rescue LDAP::ResultError
conn.perror("search")
exit
end
conn.perror("search")
conn.unbind
end
我在这部分中使用此方法:
def addAccount
conn = LDAP::Conn.new($HOST, $PORT)
conn.bind('cn=admin, dc=-, dc=-, dc=de','-')
conn.perror("bind")
pw=params[:userpassword]
genPasswd(pw)
getGridNumber(params[:group])
for i in 2000 ... 7000 do
filter = 'uidNumber='+i.to_s
array=conn.search2($base, $scope, filter, ['*'])
if array.size == 0 then
@uidnumber=i
break
end
end
entry = [
LDAP.mod(LDAP::LDAP_MOD_ADD,'objectClass',["account","posixAccount","top","shadowAccount","sambaSamAccount","eClara"]),
LDAP.mod(LDAP::LDAP_MOD_ADD,'uid',params[:uid].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'uidNumber',[@uidnumber.to_s]),
LDAP.mod(LDAP::LDAP_MOD_ADD,'gidNumber',[@gridNumber]),
LDAP.mod(LDAP::LDAP_MOD_ADD,'homeDirectory',['/home/stadler/tool/test/'+params[:uid]]),
LDAP.mod(LDAP::LDAP_MOD_ADD,'gecos',params[:gecos].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'shadowLastChange',params[:shadowlastchange].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaLogoffTime',params[:sambalogofftime].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'displayName',params[:displayname].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'cn',params[:uid].split()),
#LDAP.mod(LDAP::LDAP_MOD_ADD,'loginShell',params[:loginshell].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'loginShell',['/bin/bash']),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaLMPassword',params[:sambalmpassword].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaNTPassword',params[:sambantpassword].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaLogonTime',params[:sambalogontime].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'userPassword',[@slappedpwd]),
LDAP.mod(LDAP::LDAP_MOD_ADD,'lernStatus1',params[:lernstatus1].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaPwdMustChange',params[:sambapwdmustchange].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaKickoffTime',params[:sambakickofftime].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaPwdCanChange',params[:sambapwdcanchange].split()),
LDAP.mod(LDAP::LDAP_MOD_ADD,'sambaSID',params[:sambasid].split()),
]
begin
address= 'uid='+params[:uid]+', ou=Users, dc=cippool-mb, dc=rwth-aachen, dc=de'
conn.add(address, entry)
FileUtils.mkdir '/home/stadler/tool/test/'+params[:uid], :mode => 0700
FileUtils.chown 'stadler', 'stadler', '/home/stadler/tool/test/'+params[:uid]
FileUtils.remove_dir('tmp')
flash[:success] = "Account added!"
rescue LDAP::ResultError
conn.perror("add")
flash[:error] = "WTF!!!!! Already there! "
#exit
end
conn.perror("add")
conn.unbind
redirect_to :action => "getAllAccounts"
end
我尝试获取更多信息,但首先,有人可以告诉我错误的参数类型#<Class:0xb996604>
(预期的数据)是什么意思?