Query LDAP users better ways through Ruby Net-LDAP?

Is there a better way to search for users and computers that specifically use the Net-ldap gem?

This is what I currently do just to get users.

results = search :base => @base, :filter => Net::LDAP::Filter.eq("cn", "*")
@results = Array.new

results.each do |result|
@results. push result if result[:objectclass].include? "person" unless result[:objectclass].include? "computer"

There seems to be a better way. I can’t see anything obvious in the documentation Things.

you can use the join filter function of net-ldap:

filter = Net::LDAP::Filter.eq("sAMAccountName", "*")
filter2 = Net::LDAP::Filter.eq("objectCategory ", "organizationalPerson")

joined_filter = Net::LDAP::Filter.join(filter, filter2)

ldap.search(:base => treebase, :filter => joined_filter) do |entry|
puts entry.sAMAccountName
end

Is there a better way to search specifically using the Net-ldap gem Users and computers?

This is what I currently do just to get users.

results = search :base => @base, :filter => Net::LDAP::Filter.eq("cn", "*")
@results = Array.new

results.each do |result|
@results. push result if result[:objectclass].include? "person" unless result[:objectclass].include? "computer"

There seems to be a better way. I can’t see anything obvious in the documentation Something.

You can use the Join filter function of net-ldap:

 filter = Net::LDAP::Filter.eq("sAMAccountName", "*")
filter2 = Net::LDAP::Filter.eq("objectCategory", "organizationalPerson")

joined_filter = Net::LDAP::Filter.join(filter, filter2)

ldap.search(:base => treebase, :filter => joined_filter) do |entry|
puts entry.sAMAccountName
end

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3364 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.