Actions
Defect #11447
closed"\x82" from ASCII-8BIT to UTF-8" error, when search data from LDAP
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Plugin API
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Invalid
Affected version:
Description
I'm writting plugin, that make periodicaly user's synchronisation from LDAP
When I run rake task I see the error "rake aborted! \x82" from ASCII-8BIT to UTF-8"
The command, that I run is "rake redmine:make_ldap_full_sync"
I know, that this error in net-ldap library, but it work outside rake
error cause this code
ldap_connection.search(:base => auth_source.base_dn, :filter => filter, :return_result=>0)
Any help
There is my rake task full code
# encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment") require File.expand_path(File.dirname(__FILE__) + "/../../../../config/application") class UserSync < User def self.make_ldap_sync ldap_connection=get_ldap_connection auth_source=get_auth_source #puts Setting.plugin_ldap_users_sync['root_dn'] filter = Net::LDAP::Filter.eq('objectclass', 'user') #puts "ShukinaNA@PRP.ru".split('PRP').first.encoding.name #puts auth_source.base_dn.encoding.name #puts '--------' user_logins_in_ldap=[] ldap_connection.search(:base => auth_source.base_dn, :filter => filter) { |entry| current_login = (entry.userPrincipalName.first.to_s.include? '@') ? entry.userPrincipalName.first.to_s.split('@').first : entry.userPrincipalName.to_s user_logins_in_ldap.push current_login current_user=User.find_by_login(current_login) if current_user.nil? new_user=User.new new_user.login=current_login new_user.firstname=entry[auth_source.attr_firstname].first.to_s new_user.lastname=entry[auth_source.attr_lastname].first.to_s new_user.mail=entry[auth_source.attr_mail].first.to_s new_user.language=Setting.default_language new_user.mail_notification=Setting.default_notification_option if new_user.save puts "New user #{current_login} has been created" end else current_user.mail=entry[auth_source.attr_mail].first.to_s current_user.firstname=entry[auth_source.attr_firstname].first.to_s current_user.lastname=entry[auth_source.attr_lastname].first.to_s if current_user.save puts "User info #{current_user.login} has been updated" end end } puts '----------------' puts user_logins_in_ldap.join(', '); end def self.get_ldap_connection auth_source=get_auth_source if auth_source.port == 0 port = 389 else port = auth_source.port end ldap = Net::LDAP.new :host => auth_source.host, :port => port, :auth => { :method => :simple, :username => auth_source.account, :password => auth_source.account_password } return ldap end def self.get_auth_source auth_source=AuthSource.first end end namespace :redmine do task :make_ldap_full_sync => :environment do UserSync.make_ldap_sync end end
Output:
User info KryukovaEA has been updated User info OvsyanikovaAI has been updated User info OputinaNM has been updated User info PalinskayaOV has been updated User info zaslavskaya has been updated User info AnnenkovaVV has been updated User info 13131 has been updated User info KubievaLS has been updated User info DavydovaOV has been updated User info OrlikIL has been updated User info GellerZHI has been updated User info KuznecovaVA has been updated User info KonovalovaMN has been updated User info EliseevaSV has been updated User info ShukinaNA has been updated rake aborted! "\x82" from ASCII-8BIT to UTF-8 Tasks: TOP => redmine:make_ldap_full_sync (See full trace by running task with --trace)
Any help is appreciated.
Updated by Jean-Philippe Lang over 12 years ago
- Status changed from New to Closed
- Resolution set to Invalid
Sorry, no plugin issue here.
Updated by Prasanth Kumar almost 12 years ago
I solved this problem by installing "net-ldap-1 v0.4.0" gem and adding this gem specification in ldap group of Gemfile
Actions