gpt4 book ai didi

ruby - net ldap - 编码::UndefinedConversionError

转载 作者:数据小太阳 更新时间:2023-10-29 07:56:57 25 4
gpt4 key购买 nike

伙计们!我收到以下错误消息,但我不知道该怎么做。这是一个已知的 net-ldap 错误吗?我试图更新我的 gem ,我已经在互联网上寻找更多信息。第一部分没问题,我从我的 ldap 数据库中获取了我的数据,但最后出现了这个错误。

/usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ber/core_ext/string.rb:23:in encode': "\x8E" from ASCII-8BIT to UTF-8
(Encoding::UndefinedConversionError) from
/usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ber/core_ext/string.rb:23:in
raw_utf8_encoded' from /usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ber/core_ext/string.rb:15:in to_ber' from
/usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ldap.rb:1396:in
block in search' from /usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ldap.rb:1367:in loop' from
/usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ldap.rb:1367:in
search' from /usr/local/lib/ruby/gems/1.9.1/gems/net-ldap-0.3.1/lib/net/ldap.rb:637:in `search'

这是我的代码:

require 'rubygems'
require 'net/ldap'

ldap = Net::LDAP.new
ldap.host = 'xxxxxx'
ldap.authenticate "cn=admin, dc=xxxx, dc=xxxxx, dc=de", "xxxxx!"
#puts ldap.bind
if ldap.bind
# authentication succeeded
else
# authentication failed
# p ldap.get_operation_result
end


filter = Net::LDAP::Filter.eq("uid", "*")
treebase = "xxxxx, dc=xxxxxx, dc=de"

ldap.search(:base => treebase, :filter => filter) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attribute, values|
puts " #{attribute}:"
values.each do |value|
puts " --->#{value}"
end
end
end

最佳答案

net-ldap [1],[2],[3],[4] v0.3.1 中存在很多编码问题。几个补丁已经合并,但遗憾的是,这个伟大的项目似乎半放弃了,并且没有将更改推送到 ruby​​gems。直接从 github 上使用它对我来说效果很好,如果你使用的是 bundler,那么在你的 Gemfile 中粘贴这样的东西很容易:

gem "net-ldap", :git => "git://github.com/ruby-ldap/ruby-net-ldap.git", :ref => '8a182675f4'

1 - https://github.com/ruby-ldap/ruby-net-ldap/pull/41
2 - https://github.com/ruby-ldap/ruby-net-ldap/pull/44
3 - https://github.com/ruby-ldap/ruby-net-ldap/pull/64
4 - https://github.com/ruby-ldap/ruby-net-ldap/pull/55

关于ruby - net ldap - 编码::UndefinedConversionError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11118353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com