请给出 Rails/Devise/LDAP Devise::LdapAdapter.get_ldap_param 用法的示例
我被困在使用 get_ldap_param 对 eDir ldap 服务器进行身份验证。我可以进行身份验证,但是当我尝试读取属性时我什么也得不到。
def get_ldap_email
self.email = Devise::LdapAdapter.get_ldap_param(self.uid, "mail")
end
def get_ldap_category
self.category = Devise::LdapAdapter.get_ldap_param(self.uid, "category")
end
在我的 ndstrace.log 中
92659520 LDAP: [2011/11/14 10:10:07.401] New cleartext connection 0xe4b26c0 from 192.168.21.40:58658, monitor = 0x4b37c940, index = 8
1256683840 LDAP: [2011/11/14 10:10:07.401] DoBind on connection 0xe4b26c0
1256683840 LDAP: [2011/11/14 10:10:07.401] Bind name:cn=admin,o=xxx, version:3, authentication:simple
1256683840 LDAP: [2011/11/14 10:10:07.401] Sending operation result 0:"":"" to connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.402] DoSearch on connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.402] Search request:
base: "cn=ntr,ou=Meta,o=xxx"
scope:0 dereference:0 sizelimit:0 timelimit:0 attrsonly:0
filter: "(objectclass=*)"
no attributes
1310226752 LDAP: [2011/11/14 10:10:07.402] Empty attribute list implies all user attributes
1310226752 LDAP: [2011/11/14 10:10:07.403] Sending search result entry "cn=ntr,ou=Meta,o=xxx" to connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.403] Sending operation result 0:"":"" to connection 0xe4b26c0
1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 found connection 0xe4b26c0 socket closed, err = -5871, 0 of 0 bytes read
1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 initiating close for connection 0xe4b26c0
1251420480 LDAP: [2011/11/14 10:10:07.405] Server closing connection 0xe4b26c0, socket error = -5871
1251420480 LDAP: [2011/11/14 10:10:07.405] Connection 0xe4b26c0 closed
登录后出现的错误:
NoMethodError in Devise::SessionsController#create
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Rails.root: /home/ntr/Dropbox/source/devise
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"nkuzPnh8MCK4rh/RXUErrAjVJB9ciy56hfavG60I8ck=",
"user"=>{"uid"=>"ntr",
"password"=>"[FILTERED]",
"remember_me"=>"0"},
"commit"=>"Logga in"}
Show session dump
Show env dump
Response
Headers:
None
我一直在网上搜索相关教程,但只找到了 devise_ldap 插件的基本实现。不使用 get_ldap_param。
很想得到一些例子、技巧等
。//Roger
I am stuck using get_ldap_param authenticating against an eDir ldap server. I can authenticate but when I try to read attributes I get nothing.
def get_ldap_email
self.email = Devise::LdapAdapter.get_ldap_param(self.uid, "mail")
end
def get_ldap_category
self.category = Devise::LdapAdapter.get_ldap_param(self.uid, "category")
end
In my ndstrace.log
92659520 LDAP: [2011/11/14 10:10:07.401] New cleartext connection 0xe4b26c0 from 192.168.21.40:58658, monitor = 0x4b37c940, index = 8
1256683840 LDAP: [2011/11/14 10:10:07.401] DoBind on connection 0xe4b26c0
1256683840 LDAP: [2011/11/14 10:10:07.401] Bind name:cn=admin,o=xxx, version:3, authentication:simple
1256683840 LDAP: [2011/11/14 10:10:07.401] Sending operation result 0:"":"" to connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.402] DoSearch on connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.402] Search request:
base: "cn=ntr,ou=Meta,o=xxx"
scope:0 dereference:0 sizelimit:0 timelimit:0 attrsonly:0
filter: "(objectclass=*)"
no attributes
1310226752 LDAP: [2011/11/14 10:10:07.402] Empty attribute list implies all user attributes
1310226752 LDAP: [2011/11/14 10:10:07.403] Sending search result entry "cn=ntr,ou=Meta,o=xxx" to connection 0xe4b26c0
1310226752 LDAP: [2011/11/14 10:10:07.403] Sending operation result 0:"":"" to connection 0xe4b26c0
1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 found connection 0xe4b26c0 socket closed, err = -5871, 0 of 0 bytes read
1261947200 LDAP: [2011/11/14 10:10:07.405] Monitor 0x4b37c940 initiating close for connection 0xe4b26c0
1251420480 LDAP: [2011/11/14 10:10:07.405] Server closing connection 0xe4b26c0, socket error = -5871
1251420480 LDAP: [2011/11/14 10:10:07.405] Connection 0xe4b26c0 closed
The error I get after logging in:
NoMethodError in Devise::SessionsController#create
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Rails.root: /home/ntr/Dropbox/source/devise
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"nkuzPnh8MCK4rh/RXUErrAjVJB9ciy56hfavG60I8ck=",
"user"=>{"uid"=>"ntr",
"password"=>"[FILTERED]",
"remember_me"=>"0"},
"commit"=>"Logga in"}
Show session dump
Show env dump
Response
Headers:
None
I've been searching high and low for some kind of tutorials for this on the web but only found basic implementations of the devise_ldap addon. Non using get_ldap_param.
Would love to get some examples, tips etc.
//Roger
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
dstrace 显示您正在获取返回的所有属性:
空属性列表意味着所有用户属性
但它不再在 dstrace 中显示返回的数据。较旧的 eDirectory 曾一度在跟踪中显示结果,但现在已经很长时间了。
所以我建议 eDir 将数据发回。现在介绍您的应用程序如何解析该响应。
The dstrace is showing that you are getting all the attributes returned:
Empty attribute list implies all user attributes
But it does not show the returned data in dstrace anymore. Older eDirectory at one point did show the results in trace but not for a long time now.
So I would suggest eDir is sending the data back. Now on to how your app is parsing that response.
部分问题在于,目前 devise_ldap_authenticatable gem 不会将身份验证密码传递给此函数。
一个
我希望有一个回调,其中 可以从身份验证的 LDAP 响应中获得更多信息,但这似乎不可能。
The problem, in part, is that currently, devise_ldap_authenticatable gem does not pass in an authentication password to this function.
https://github.com/cschiewek/devise_ldap_authenticatable/issues
I wish there was a callback where one could extra more out of the LDAP response from authentication, but that doesn't seem possible.