2011-11-14 61 views
2

我被困在使用get_ldap_param對eDir ldap服務器進行驗證的情況。我可以進行身份​​驗證,但是當我嘗試讀取屬性時,我什麼也得不到。請舉例說明Rails/Devise/LDAP Devise :: LdapAdapter.get_ldap_param的用法

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。

很想得到一些例子,技巧等

//羅傑

回答

1

的DSTRACE正顯示出你所得到的所有屬性返回:

Empty attribute list implies all user attributes

但它確實不再顯示在dstrace中返回的數據。較早的eDirectory在一段時間內確實顯示了結果,但現在已經很長一段時間了。

所以我建議eDir發回數據。現在談談你的應用如何解析該響應。

+0

除了get_ldap_param方法,我沒有在我的應用程序中進行任何解析,並且我在電子郵件和類別的遷移中添加了列。我還在我的用戶模型中添加了:email和:category到attr_accessible。 –

+0

正如你所說的geoffc ...問題是什麼是ldap返回?我是否在問ldap錯誤的問題,因爲它認爲它應該會返回所有內容。我顯然在我的對象中有一個郵件屬性,但是我的LDAP服務器說查詢是空的? –