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:
p>
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