ldap/netを使用してActive Directoryへの接続を確立しました。私はADの属性と値を取得しようとしています。レールからアクティブなディレクトリにアクセスする際のObservationsのEncoding :: CompatibilityError
(values.inspectを使用して)次のコードを使用すると、クエリが機能します。たとえば、givennameに -
<% @temp_search.each do |user| %>
TS = <%= user.sn %> <br>
<% user.each do |attribute, values| %>
<%= attribute %> <br>
<% values.each do |value| %>
<%= value.inspect %><br>
<% end %>
<hr style="border-color: red">
<% end %>
<% end %>
LDAPクエリをやって私のコントローラの部分がs
ただ一つの特定の属性の値を取得することです私は何をするように見えることはできませんfilter = Net::LDAP::Filter.eq("sn", "mendla")
treebase = "dc=ccttapes1,dc=com"
@temp_search = ldap.search(:base => treebase, :filter => filter)
p ldap.get_operation_result
です。私は
NoMethodError in Observations#index
Showing C:/Users/cmendla/RubymineProjects/employee_observations/app/views/observations/index.html.erb where line #61 raised:
undefined method `givenname' for "CN=Christopher Mendla,OU=Users CCT,DC=CCTTAPES1,DC=com":Net::BER::BerIdentifiedString
Rails.root: C:/Users/cmendla/RubymineProjects/employee_observations
Application Trace | Framework Trace | Full Trace
app/views/observations/index.html.erb:61:in `block (3 levels) in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:60:in `each'
app/views/observations/index.html.erb:60:in `block (2 levels) in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:58:in `block in _app_views_observations_index_html_erb__474218211_78240600'
app/views/observations/index.html.erb:56:in `each'
app/views/observations/index.html.erb:56:in `_app_views_observations_index_html_erb__474218211_78240600'
のエラーを取得し、<%= value.inspect %><br>
<%= value.givenname %><br>
に変更した場合
私は、しかし、そのような
cn
"Chris G. Mendla"
sn
"Mendla"
description
"Test account 1 for rails apps - DO NOT CHANGE PW"
givenname
"Chris"
initials
"G"
distinguishedname
"CN=Chris G. Mendla,OU=Users CCT,DC=CCTTAPES1,DC=com"
として結果を参照してください、私がしようとした場合、 `` <% = givenname.value%> `私は得る
NameError in Observations#index
Showing C:/Users/cmendla/RubymineProjects/employee_observations/app/views/observations/index.html.erb where line #61 raised:
undefined local variable or method `givenname' for #<#<Class:0x9cd0230>:0x9fadaf0>
Rails.root: C:/Users/cmendla/RubymineProjects/employee_observations
Application Trace | Framework Trace | Full Trace
app/views/observations/index.html.erb:61:in `block (3 levels) in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:60:in `each'
app/views/observations/index.html.erb:60:in `block (2 levels) in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:58:in `block in _app_views_observations_index_html_erb__474218211_83715540'
app/views/observations/index.html.erb:56:in `each'
app/views/observations/index.html.erb:56:in `_app_views_observations_index_html_erb__474218211_83715540'
Request
私の目標は、AD rを検索できるようにすることです最初と最後の名前でecordを作成し、mailやmemberofなどの属性の値を取得します。
(私は@temp_search
検索条件を満たしているユーザーの配列でなければなりませんあなたの例では、LDAPネット